管理用户

SQL> conn / as sysdba
已链接。
SQL> drop user violet cascade;
session

用户已删除。ide

SQL> host clsspa

SQL> --建立一个名叫violet 密码password的用户
SQL> create user violet identified by password;
对象

用户已建立。it

SQL> conn / as sysdba
已链接。
SQL> drop user emi cascasde;
drop user emi cascasde
              *
第 1 行出现错误:
ORA-00921: 意外的 SQL 命令结尾
io


SQL> drop user emi cascade;table


用户已删除。select

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