免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 981 | 回复: 0

oracle 常用命令 [复制链接]

论坛徽章:
0
发表于 2011-12-23 01:56 |显示全部楼层

Oracle 系统命令
1
、连接数据库

Sql代码

SQL> conn 用户名/密码@网络服务名SID [as sysdba/sysoper]   当用特权用户身份连接的时,必须带上as sysdba或者as sysoper  

SQL> conn 用户名/密码@网络服务名SID [as sysdba/sysoper]   当用特权用户身份连接的时,必须带上as sysdba或者as sysoper


2
、显示当前用户

Sql代码

SQL> show user;  

SQL> show user;


3
、修改密码

Sql代码

管理员自己修改密码: passw    管理员修改其他用户密码: passw  用户名    

管理员自己修改密码: passw    管理员修改其他用户密码: passw  用户名 


4
、退出

Sql代码

SQL> exit;  

SQL> exit;


5
、运行sql脚本

Sql代码

SQL> start c:\test.sql; 或者SQL> @ c:\test.sql;  

SQL> start c:\test.sql;或者SQL> @ c:\test.sql;


6
、编辑sql脚本

Sql代码

SQL> edit c:\test.sql;  

SQL> edit c:\test.sql;


7
、将指定查询内容输出到指定文件中去
emp表中的数据放在d:\test.sql这个文件中

Sql代码

SQL> spool d:\test.sql;  

SQL> select * from emp;  

SQL> sppool off;  

SQL> spool d:\test.sql;

SQL> select * from emp;

SQL> sppool off;



Oracle
用户管理
切换用户

Sql代码

SQL> conn system/manager  

SQL> conn system/manager


创建用户

Sql代码

SQL> create user 用户名  identified by 密码  

SQL> create user 用户名  identified by 密码


修改别人密码

Sql代码

SQL> password 用户名  

SQL> alter user 用户名 identified by 新密码  

SQL> password 用户名

SQL> alter user 用户名 identified by 新密码


删除用户(自己删除自己不可以)
如果要删除用户,并且同时要删除用户所创建在表,那么就需要在删除时带一个参数cascade;

Sql代码

SQL> drop user 用户名 [cascade]  

SQL> drop user 用户名 [cascade]





角色管理权限
受理连接数据库权限(connect)给一个用户

Sql代码

SQL> grant connect to 用户名  

SQL> grant connect to 用户名


授权username查询emp权限

Sql代码

SQL> grant select on emp to username  

SQL> grant insert on emp to username  

SQL> grant update on emp to username  

SQL> grant delete on emp to username  

SQL> grant select on emp to username

SQL> grant insert on emp to username

SQL> grant update on emp to username

SQL> grant delete on emp to username



授权usernameemp所有权限

Sql代码

SQL> grant all on emp to username  

SQL> grant all on emp to username



权限传递
如果是对象权限,权限在传递就在后面加with grant option

Sql代码

SQL> grant select on emp to username with grant option  

SQL> grant select on emp to username with grant option



如果是系统权限,权限在传递就在后面加with admin option 这使username可以把select权限传递给其他人

Sql代码

SQL> grant connect on emp to username with admin option  

SQL> grant connect on emp to username with admin option



收回username在我的emp表上在select权限

Sql代码

SQL> revoke select on emp from username  

SQL> revoke select on emp from username



profile
规则
账户锁定
指定账户登陆最多可以输入密码在次数,也可以指定用户锁定在时间()一般用dba在身份去执行该命令

Sql代码

SQL> create profile lock_account limit failed_login_attempts 3 password_lock_time 2;  

lock_account: 名称随便取名  

3:最多输入3次密码  

2:锁定2  

其他的都是关键字  

SQL> create profile lock_account limit failed_login_attempts 3 password_lock_time 2;

lock_account:名称随便取名

3:最多输入3次密码

2:锁定2

其他的都是关键字



把锁lock_accountscott.如果用户连续输入3次错误密码,那么你就被锁定2,2天后才能登陆

Sql代码

SQL> alter user scott profile lock_account;  

SQL> alter user scott profile lock_account;

 

 

  。。。。。。。。待续

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP