1、创建用户
create user 用户名 identified by 密码
2、授权
2.1 授予连接权限
grant create session to 用户名
2.2 授予查询所有表权限
select 'grant select on'||table_name||'to 用户名;' from user_tables;
2.3 授予创建同义词权限
grante create synonym to 用户名
grant unlimited tablespace to 用户;--授予用户使用表空间的权限
grant create table to 用户;--授予创建表的权限
grant drop table to 用户;--授予删除表的权限
grant insert table to 用户;--插入表的权限
grant update table to 用户;--修改表的权限
grant all to public;--授予所有权限(all)给所有用户(public)
grant select on 表名 to 用户;--授予zhangsan用户查看指定表的权限
grant drop on 表名 to 用户;--授予删除表的权限
grant insert on 表名 to 用户;--授予插入的权限
grant update on 表名 to 用户;--授予修改表的权限
grant insert(id) on 表名 to 用户;--授予对指定表特定字段的插入权限
grant update(id) on 表名 to 用户;--授予对指定表特定字段的修改权限。注意:对特定字段只能是insert和update
3、撤销权限
3.1 撤销查询权限
revoke select on 表名 from 用户名
4、建立同义词
A建立B用户之后,在B用户上直接查询表名会提示表名不存在。进行A.表名才可以查询出来。因此需要在B用户处建立同义词,使得查询简便。
create synonym 表名 for A.表名