玩转Oracle(2)

来源:互联网 发布:h5游戏源码购买 编辑:程序博客网 时间:2024/04/27 14:37

sql*plus 命令


 

//执行脚本
@和start d:/a.txt;

 

//修改脚本
edit d:/a.txt;

//将内容输入到文本中


sloop d:/a.txt;  //开始记录屏幕内容
sloop off;  //记录结束

//链接登录数据库


connect system/919959 as sysdba/sysoper;  //权限最大dba
connect sys/919959;
connect scott/tiger;

 

//创建用户
create user valen identified by 919959;  //创建完成后并不能够登录,需要授权

 

//当前用户
show user;

 

//删除用户
drop user valen;

 

//授权
grant connect to valen;  //登录的权限
grant resource to valen; //建表的权限
grant select on emp to valen; //将对象操作权限给予某一个用户,假设当前用户为scott,将scott的emp表的select权限赋给valen
grant update on emp  //更新权限
grant inset on emp  //添加权限
grant delete on emp  //删除权限
grant all on emp  //当前表的所有权限

 

//收回权限
revoke select on emp from valen; //从valen用户收回对emp表的select权限

 

//查询其他用户的表的权限
select * from scott.emp  //查询scott用户下emp表

 

//权限的维护
//对象权限
scott将权限传给了valen,并希望valen将该选线继续传递给下一个用户
grant select on emp to valen with grant option //如果是对象权限就加入with grant option

 

//系统权限
grant connect to valen with admin option //如果是系统权限就加入with admin option
如果scott收回了valen的权限,则valen授权给tom的权限也被收回了

 

//使用profile管理用户口令
创建profile文件
create profile lock_account //创建规则lock_account
limit    //关键字
failed_login_attempts 3  //给予3次登录机会
password_lock_time 2;  //锁定2天

 

//更改用户遵循此规则
alter user tom profile lock_account;

 

//给账户解封
alter user tom account unlock; //给指定用户解封

 

//终止口令
create profile myprofile //创建规则myprofile
limit
password_life_time 10  //每10天修改登录密码
password_grace_time 2  //宽限期为2天
password_reuse_time 10  //指定口令可重用时间即10天后就可以重用

 

//删除profile文件
drop profile lock_account cascade ; //cascade是解除被规则的用户

原创粉丝点击