您的位置:首页 > 数据库 > Oracle

管理用户

2014-11-23 22:36 363 查看
SQL> conn / as sysdba

已连接。

SQL> drop user violet cascade;

用户已删除。

SQL> host cls

SQL> --创建一个名叫violet 密码password的用户

SQL> create user violet identified by password;

用户已创建。

SQL> conn / as sysdba

已连接。

SQL> drop user emi cascasde;

drop user emi cascasde

              *

第 1 行出现错误:

ORA-00921: 意外的 SQL 命令结尾

SQL> drop user emi cascade;

用户已删除。

SQL> drop user jeff cascade;

用户已删除。

SQL> host cls

SQL> create user jeff identified by password;

用户已创建。

SQL> create user emi identified by password;

用户已创建。

SQL> grant create session to jeff,emi;

授权成功。

SQL> --使用admin option

SQL> show user

USER 为 "SYS"

SQL> grant create table to jeff with admin option;

授权成功。

SQL> --分配配额

SQL> alter user jeff quota unlimited on users;

用户已更改。

SQL> --切换到jeff上

SQL> conn jeff/password

已连接。

SQL> create table ddd( d number);

表已创建。

SQL> --jeff: create table ---> emi

SQL> show user

USER 为 "JEFF"

SQL> grant create table to emi;

授权成功。

SQL> conn / as sysdba

已连接。

SQL> alter user emi quota unlimited on users;

用户已更改。

SQL> conn emi/password

已连接。

SQL> create table ddd( d number);

表已创建。

SQL> --撤销jeff的权限

SQL> conn / as sysdba

已连接。

SQL> revoke create table from jeff;

撤销成功。

SQL> conn jeff/password

已连接。

SQL> create table daa(d number);

create table daa(d number)

*

第 1 行出现错误:

ORA-01031: 权限不足

SQL> conn emi/password

已连接。

SQL> create table daa(d number);

表已创建。

SQL> conn scott/tiger

已连接。

SQL> host cls

SQL> --使用grant option撤销对象权限

SQL> show user

USER 为 "SCOTT"

SQL> grant select on emp to jeff with grant option;

授权成功。

SQL> conn jeff/password

已连接。

SQL> select count(*) from scott.emp;

  COUNT(*)                                                                     

----------                                                                     

        15                                                                     

SQL> --jeff: ---> emi

SQL> show user

USER 为 "JEFF"

SQL> grant select on scott.emp to emi;

授权成功。

SQL> conn emi/password;

已连接。

SQL>  select count(*) from scott.emp;

  COUNT(*)                                                                     

----------                                                                     

        15                                                                     

SQL> host cls

SQL> conn scott/tiger

已连接。

SQL> revoke select on emp from jeff;

撤销成功。

SQL> conn jeff/password

已连接。

SQL>  select count(*) from scott.emp;

 select count(*) from scott.emp

                            *

第 1 行出现错误:

ORA-00942: 表或视图不存在

SQL> conn emi/password

已连接。

SQL>  select count(*) from scott.emp;

 select count(*) from scott.emp

                            *

第 1 行出现错误:

ORA-00942: 表或视图不存在

SQL> host cls

SQL> --角色

SQL> show user

USER 为 "EMI"

SQL> conn / as sysdba

已连接。

SQL> drop role hr_mgr;

角色已删除。

SQL> drop role hr_clerk;

角色已删除。

SQL> create role hr_mgr;

角色已创建。

SQL> create role hr_clerk;

角色已创建。

SQL> --create session, create table

SQL> --把权限授予给角色

SQL> grant create session to hr_clerk;

授权成功。

SQL> grant create table,hr_clerk  to hr_mgr;

授权成功。

SQL> --把角色授予个用户

SQL> grant  hr_clerk to jeff;

授权成功。

SQL> grant hr_mgr to emi;

授权成功。

SQL> /*

SQL> create user myuser identified by password;

SQL> grant connect,resource to myuser;

SQL> 创建用户

SQL> */

SQL> spool off


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  oracle grant