oracle user creation and permission settings

Permissions:

  create session

  create table

  unlimited tablespace

  connect

  resource

  dba

  example:

  #sqlplus /nolog

  SQL> conn / as sysdba;

  SQL>create user username identified by password

  SQL> grant dba to username;

  SQL> conn username/password

  SQL> select * from user_sys_privs;

  We will start with the creation of the Oracle user permission table, and then explain the general actions such as login, so that everyone has a deep understanding of the Oracle user permission table.

  1. Create

  sys;//System administrator, has the highest authority

  system;//Local administrator, second highest authority

  scott;//Ordinary user, the password is tiger by default, and the default is not unlocked

  2. Login

  sqlplus / as sysdba;//Log in to the sys account

  sqlplus sys as sysdba;//同上

  sqlplus scott/tiger;//Log in to the ordinary user scott

  3. Manage users

  create user zhangsan;//Under the administrator account, create user zhangsan

  alert user scott identified by tiger;//modify password

  Fourth, grant permissions

  1. The default ordinary user scott is not unlocked by default and cannot be used for that purpose. The newly created user does not have any permissions and must be granted permissions.

  

  grant create session to zhangsan;//Grant user zhangsan the permission to create a session, that is, login permission

  grant unlimited tablespace to zhangsan;//Grant user zhangsan permission to use tablespace

  grant create table to zhangsan;//授予创建表的权限

  grante drop table to zhangsan;//授予删除表的权限

  grant insert table to zhangsan;//插入表的权限

  grant update table to zhangsan;//修改表的权限

  grant all to public;//这条比较重要,授予所有权限(all)给所有用户(public)

  2、oralce对权限管理比较严谨,普通用户之间也是默认不能互相访问的,需要互相授权

  

  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任意表的权限

  五、撤销权限

  基本语法同grant,关键字为revoke

  六、查看权限

  select * from user_sys_privs;//查看当前用户所有权限

  select * from user_tab_privs;//查看所用用户对表的权限

  七、操作表的用户的表

  

  select * from zhangsan.tablename

  八、权限传递

  即用户A将权限授予B,B可以将操作的权限再授予C,命令如下:

  grant alert table on tablename to zhangsan with admin option;//关键字 with admin option

  grant alert table on tablename to zhangsan with grant option;//关键字 with grant option效果和admin类似

  九、角色

  角色即权限的集合,可以把一个角色授予给用户

  create role myrole;//创建角色

  grant create session to myrole;//将创建session的权限授予myrole

  grant myrole to zhangsan;//授予zhangsan用户myrole的角色

  drop role myrole;删除角色

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326175876&siteId=291194637