曾梦垚

导航

Oracle创建用户、授权、规则

---用户登录命令
--管理员登录
conn sys/oracle as sysdba;
--创建用户方案必须是管理员权限
--创建用户命令 create user useranme identifild by password
create user god identified by g123;
--管理员授权 系统 权限 grant ..to...
grant connect,resource,dba to god;
--管理员授权 对象 权限
grant xx on tablename to username;
--取消授权---
revoke xx from username;
revoke xx on tablename from username;
---权限传递
--1 with admin option 系统权限传递
--管理员给予zhangsan connect,resource 的权限的同时,zhangsna 可以授予其他用户
grant connect,resource to zhangsan with admin option;
--2 with grant option 对象权限传递
grant select on scott.emp to zhangsan with grant option;
--god登录
--创建表
create table student( sid int,sname varchar2(30));
--解锁---
--scott方案默认是被锁定
--管理员才有权限解锁,锁定
alter user scott account unlock;
alter user scott account lock;

 


---举例
--创建2个用户方案,A zhangsan/z123 ,B lisi/l123
--给A授权 connect,resouce权限
--在A方案下面创建一张student表
--通过A授予B connect权限
create user zhangsan identified by z123;
create user lisi identified by l123;
grant connect,resource to zhangsan;


---删除用户
drop user username
drop user lisi;
--级联删除
drop user username cascade;

---创建规则
create profile 规则名称 limit failed_login_attempts 次数 password_lock_time 天数
create profile pwdlock limit failed_login_attempts 3 password_life_time 1000;
--创建用户
create user zhangsan identified by z123;
--给登录权限
grant connect to zhangsan;
--给规则
alter user zhangsan profile pwdlock;
---如果输入3次密码错误就会锁定 需要解锁
alter user zhangsan account unlock;

 

posted on 2017-02-24 20:54  曾梦垚  阅读(276)  评论(0编辑  收藏  举报