【Vegas原创】Oracle批量create、Lock user的方法
1,create 一个user的方法:
CREATE USER SP0704166
IDENTIFIED BY lijuan
DEFAULT TABLESPACE BACH
TEMPORARY TABLESPACE TEMP01
PROFILE DEFAULT;
--grant user SP0704166 some privileges
GRANT CREATE SESSION TO SP0704166;
GRANT CREATE ANY TABLE TO SP0704166;
GRANT SELECT ANY TABLE TO SP0704166;
GRANT DELETE ANY TABLE TO SP0704166;
GRANT INSERT ANY TABLE TO SP0704166;
GRANT UPDATE ANY TABLE TO SP0704166
2,create多个user的方法:
例:client提供user的excel表且规定:用户名:SP+工号;密码:英文名
EMP_NO | LOGIN_NAME | EMP_NAME |
0805480 | xueqing jiang | 蒋雪情 |
0710329 | xiaofang qi | 戚小芳 |
0707159 | xingxing ding | 丁星星 |
0712292 | pengfei zhang | 张鹏飞 |
step1,打开excel,用分列方法,将login_Name的名和姓按空格分开。
step2,在对应的G1单元格里,输入:
="CREATE USER SP"&A2&" IDENTIFIED BY "&B2&" DEFAULT TABLESPACE BACH TEMPORARY TABLESPACE TEMP01 PROFILE DEFAULT;"
step3,下拉,同步所有
step4,copy至IDE,Run
3,grant多个user的方法:
step1,在对应的F1单元格里输入:
="GRANT CREATE SESSION TO SP"&A2&";
GRANT CREATE ANY TABLE TO SP"&A2&";
GRANT SELECT ANY TABLE TO SP"&A2&";
GRANT DELETE ANY TABLE TO SP"&A2&";
GRANT INSERT ANY TABLE TO SP"&A2&";
GRANT UPDATE ANY TABLE TO SP"&A2&";"
or
="GRANT CREATE SESSION,CREATE ANY TABLE,SELECT ANY TABLE,DELETE ANY TABLE,INSERT ANY TABLE,UPDATE ANY TABLE TO SP"&A2&";"
step2,下拉同步所有;
step3,copy至IDE,RUN
PS:Excel中回车用:Alt+Enter
4,lock多个user的方法:
step1,执行:
select 'alter user ' || username || ' account lock' || ';' from dba_users
where default_tablespace in ('DAXON','USERS','BACH')
and username like 'SP0%'
order by username ;
step2,将结果copy,再次执行,即可。