//创建操作系统用户
REM Creating OPS$ accounts
create user OPS$FARMER
identified by SOME_PASSWORD
default tablespace USERS
temporary tablespace TEMP;
REM Using identified externally
create user OPS$FARMER
identified externally
default tablespace USERS
temporary tablespace TEMP;
//执行ORAPWD
ORAPWD FILE=filename PASSWORD=password ENTRIES=max_users
create role APPLICATION_USER;
grant CREATE SESSION to APPLICATION_USER;
create role DATA_ENTRY_CLERK;
grant select, insert on THUMPER.EMPLOYEE to DATA_ENTRY_CLERK;
grant select, insert on THUMPER.TIME_CARDS to DATA_ENTRY_CLERK;
grant select, insert on THUMPER.DEPARTMENT to DATA_ENTRY_CLERK;
grant APPLICATION_USER to DATA_ENTRY_CLERK;
grant DATA_ENTRY_CLERK to MCGREGOR;
grant DATA_ENTRY_CLERK to BPOTTER with admin option;
//设置角色
set role DATA_ENTRY_CLERK;
set role NONE;
//回收权利:
revoke delete on EMPLOYEE from PETER;
revoke all on EMPLOYEE from MCGREGOR;
//回收角色:
revoke ACCOUNT_CREATOR from HELPDESK;
drop user USERNAME cascade;
grant SELECT on EMPLOYEE to MCGREGOR with grant option;
grant SELECT on THUMPER.EMPLOYEE to BPOTTER with grant option;
revoke SELECT on EMPLOYEE from MCGREGOR;
create user MCGREGOR identified by VALUES ’1A2DD3CCEE354DFA’;
alter user OPS$FARMER identified by VALUES ’no way’;
//备份与恢复
使用 export 程序
exp system/manager file=expdat.dmp compress=Y owner=(HR,THUMPER)
exp system/manager file=hr.dmp owner=HR indexes=Y compress=Y
imp system/manager file=hr.dmp full=Y buffer=64000 commit=Y
//备份表
exp system/manager FILE=expdat.dmp TABLES=(Thumper.SALES)
//备份分区
exp system/manager FILE=expdat.dmp TABLES=(Thumper.SALES:Part1)
//输入例子
imp system/manager file=expdat.dmp
imp system/manager file=expdat.dmp buffer=64000 commit=Y
exp system/manager file=thumper.dat owner=thumper grants=N
indexes=Y compress=Y rows=Y
imp system/manager file=thumper.dat FROMUSER=thumper TOUSER=flower
rows=Y indexes=Y