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

韩顺平oracle视频笔记一

2013-12-04 09:55 363 查看
使用@或者Start运行脚本
sql>@ c:\insert.sql
sql>start c:\delete.sql

只能由dba角色才能创建用户
create user huangbiao identified by huangbiao;

 

权限
connect      可以连接到数据的权限
resource    可以在任何表空间中可以建表
dba            拥有管理员的权限

 

创建一个用户之后是没有任何操作权限的,即不能访问任何一张表,也不能对数据库中的任何对象进行操作

分配resource角色之后,xiaoming就能自己建表了
grant resource to xiaoming;

将scott.emp表的select权限给xiaoming
grant select on scott.emp to xiaoming;

不同的用户可以创建完全两张完全相同的表,因为orcl是按照名空间为单位的。

grant update on scott.emp to xiaoming;

希望xiaoming用户可以对emp表进行所有的操作
grant all on scott.emp to xiaoming;

收回权限
revoke select on scott.emp from xiaoming;

 

权限传递(with grant option)
----对象权限的传递
grant select on scott.emp to xiaoming with grant option;
----系统权限的传递
grant connect to xiaoming with admin option

 

如果scott把xiaoming的emp表的select权限回收了,那么xiaohong的权限是什么情况?
1、revoke select on scott.emp from xiaoming;

4000
果:xiaohong的权限也被回收了

 

 

profile(资源限定的命令集合)管理用户口令
账户锁定
指定账户登录时最多可以输入的次数,也可以指定用户锁定的时间,一般用dba的身份去执行该命令
1、创建一个profile文件
create profile lock_account limit failed_login_attempts 3 password_lock_time 2;
备注:lock_account是profile的名称
      2 代表锁定2天

alter user xiaoming profile  lock_account;
给xiaoming这个用户解锁
alter user xiaoming account unlock;

终止口令(让用户定期更改密码)
create profile myprofile limit password_lift_time 10 password_grace_time 2;
alter user xiaoming profile myprofile;

口令历史
create profile password_history limit password_life_time 10 password_grace_time 2 password_reuse_time 10;
password_reuse_time指定口令可以重用时间即10天后就可以重复使用

删除profile
drop profile password_history;

自学任务
1、huangbiao有scott.emp表权限传递的权限,创建一个用户biaobiao,然后由huangbiao传递scott.emp表的select权限给biaobiao,然后删除huangbiao关于scott.emp表的所有权限,再查看biaobiao是否还有对emp表操作权限
conn system/admin as sysdba;
grant all on scott.emp to huangbiao with grant option;
create user biaobiao identified by biaobiao;
grant connect to biaobiao;
conn huangbiao/huangbiao;
grant select on scott.emp to biaobiao;
conn biaobiao/biaobiao;
select * from scott.emp;
conn system/admin as sysdba;
revoke all on scott.emp from huangbiao;
conn biaobiao/biaobiao;
select * from scott.emp;
备注:从上面的例子可以看出,关于“对象权限的传递”是采用“诛连”的方式,如果头没有了,之前被他赋予的权限也将全部删除掉了。

 

2、限定huangbiao用户只能输入三次,如果三次都是错误那么需要两天之后才能继续使用,然后再手动的修改允许huangbiao用户可以使用
create profile my_profile limit failed_login_attemps 3 password_lock_time 2;
alter user huangbiao profile my_profile;
conn huangbiao/ss;//输入三次都是错误的密码
conn huangbiao/huangbiao;//这次输入的是正确的密码,结果登录被拒绝
conn system/admin as system;
alter user huangbiao account unlock;
conn  huangbiao/huangbiao;
show user;

 

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