1.使用代码创建用户
CREATE USER qqq IDENTIFIED BY qqq123--用户名:qqq;密码:
qqq123
DEFAULT TABLESPACE tt;--用户默认表空间:tt
GRANT CONNECT TO qqq;--授权用户qqq的连接(CONNECT)权限
2.用户解锁/锁定
ALTER USER qqq ACCOUNT UNLOCK;
ALTER USER qqq ACCOUNT LOCK;
3.用户表授权
GRANT SELECT ON SCOTT.DEPT TO qqq;
REVOKE SLEECCT ON SCOTT.DEPT FROM qqq;
4.修改用户默认表空间
ALTER USER qqq DEFAULT TABLESPACE users;
5.修改用户密码
ALTER USER qqq IDENTIFIED BY qqq123;
6.对象授权
GRANT SELECT ON SCOTT.DEPT TO qqq WITH GRANT OPTION;--SELECT
,INSERT,UPDATE,DELETE,ALL
GRANT EXECUTE ON qqq.proc01 TO test;--将qqq的一个过程proc01
授权给test用户;
7.系统授权
GRANT CREATE USER TO test;--将创建用户权限给test用户。DROP
USER,CREATE USER;WITH ADMIN OPTION(给用户以授权其他用户的权
限)
REVOKE CREATE USER FROM test;
8.角色授权
CREATE ROLE myrole;
GRANT SELECT ON tt.emp TO myrole;
GRANT SELECT ON tt.deptment TO myrole;
GRANT myrole TO test;
--DEMO
connect test/test11
SELECT * FROM tt.emp;--OK
--转自