--用system用户登录,创建用户并授权
1.使用sqlplus, 以system用户连接数据:sqlplus sys/密码 as sysdba 例如:sqlplus sys/system as sysdba 1.2. 或者conn连接, system用户连接数据库: conn system/密码as sysdba 例如: conn system/system as sysdba 2.创建用户: create user 用户名 identified by 密码 例如: create user sunway identified by sunway PS : 不指定表空间和默认表空间, 则均使用默认 3.授权连接权限给用户,grant connect to 用户名 例如: grant connect to sunway 4.授权其他用户下的表的查询权限,给刚才创建的用户 grant select on 其他用户.其他用户的表 to 用户名 例如: grant select on mdm.mdm_wlzsj_query to sunway grant select on tablename to zhangsan;//授予zhangsan用户查看指定表的权限 grant drop on tablename to zhangsan;//授予删除表的权限 grant insert on tablename to zhangsan;//授予插入的权限 grant update on tablename to zhangsan;//授予修改表的权限 grant insert(id) on tablename to zhangsan; grant update(id) on tablename to zhangsan;//授予对指定表特定字段的插入和修改权限,注意,只能是insert和update grant alert all table to zhangsan;//授予zhangsan用户alert任意表的权限
示例如下:
--例如: SQL> conn system/system as sysdba; 已连接。 SQL> create user test identified by test; 用户已创建。 SQL> grant connect to test; 授权成功。 SQL> grant select on scott.emp to test; 授权成功。 SQL> conn test/test; 已连接。 SQL> select * from scott.emp;