Skip to main content

Создание пользователя в БД ORACLE

-- Шаг 1. Поменять поле [USER] и [PASSWORD]
create user [USER]
  identified by [PASSWORD]
  default tablespace USERS
  temporary tablespace TEMP
  quota unlimited on sysaux
  quota unlimited on system
  quota unlimited on users
  profile DEFAULT;
-- Grant/Revoke role privileges 
grant connect to [USER];
grant resource, ctxapp to [USER];
grant imp_full_database to [USER];
-- Grant/Revoke system privileges 
grant create procedure to [USER];
grant create sequence to [USER];
grant create synonym to [USER];
grant create table to [USER];
grant create trigger to [USER];
grant create type to [USER];
grant create view to [USER];
grant alter system to [USER];
grant alter session to [USER];
grant debug any procedure to [USER];
grant debug connect session to [USER];
-- Grant/Revoke objects
grant select on sys.v_$lock to [USER];
grant execute on SYS.DBMS_LOGMNR to [USER];
grant execute on SYS.DBMS_PROFILER to [USER];
grant select on SYS.V_$LOGMNR_CONTENTS to [USER];
grant select on SYS.V_$MYSTAT to [USER];
grant select on SYS.V_$LOGFILE to [USER];
grant select on SYS.V_$OPEN_CURSOR to [USER];
grant select on SYS.V_$SESSION to [USER];
grant select on SYS.V_$PROCESS to [USER];
grant select on SYS.DBMS_LOCK_ALLOCATED to [USER];
-- Grant/Revoke Java privileges
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' );
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'write' );
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read' );
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '' );
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '' );
call dbms_java.grant_permission(UPPER('[USER]'), 'SYS:java.net.SocketPermission', '*', 'accept,connect,listen,resolve');

grant execute on SYS.DBMS_BACKUP_RESTORE to [USER];
grant select on SYS.XKRBMSFT to [USER];

-- Job Privileges
grant all on sys.dbms_job to [USER];
grant all on sys.dba_jobs to [USER];
grant all on sys.dba_jobs_running to [USER];
grant execute on sys.dbms_lock to [USER];
grant all on sys.DBMS_CRYPTO to [USER];

---Шаг2. Создание директора для XML импортов. Заменить [UTL_DIR]
create or replace directory UTL_FILE_DIR as '[UTL_DIR]';
grant all on directory UTL_FILE_DIR to [USER];

-- шаг 3 Для BACKUP
create or replace directory backup as '[BACKUP_DIR]';
grant all on directory backup to [USER];

-- шаг 4. Импортировать схему carabi (в директории [BACKUP_DIR] должен лежать архив sirop.dmp.gz  )
gzip -d carabi7.dmp.gz 
impdp system/systempassw0rd@orcl remap_schema=carabi7:[USER] directory=BACKUP dumpfile=carabi7.dmp logfile=[USER].log TABLE_EXISTS_ACTION=REPLACE