免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1434 | 回复: 1
打印 上一主题 下一主题

[oracle] oracle工作中常用命令 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-10 22:05 |只看该作者 |倒序浏览
[oracle] oracle工作中常用命令















工作中经常用的一些命令记录下来。慢慢更新,自己做个备份。。。1.查看表空间名称,物理路径,大小,实用状况
  1. 01.select a.tablespace_name,a.bytes/1024/1024||'M' total,b.bytes/1024/1024||'M' used,c.bytes/1024/1024||'M' free,d.file_name,

  2. 02.(b.bytes*100)/a.bytes ||'%'"used",(c.bytes*100)/a.bytes||'%' " free"

  3. 03.from sys.sm$ts_avail a,sys.sm$ts_used b,sys.sm$ts_free c,dba_data_files d

  4. 04.where a.tablespace_name=b.tablespace_name and

  5. 05.a.tablespace_name=c.tablespace_name and a.tablespace_name=d.tablespace_name

  6. 06.order by tablespace_name desc ;
  7. 复制代码
复制代码
2.查看lock

  1. 01.select b.username,b.sid,b.serial#,b.logon_time,b.osuser

  2. 02.from v$locked_object a,v$session b

  3. 03.where a.session_id = b.sid order by b.logon_time;
  4. 复制代码
复制代码
3.创建表空间

  1. 01.create tablespace test

  2. 02.datafile 'c:\test.dbf' size 100m

  3. 03.autoextend on  next 64m;
  4. 复制代码
复制代码
4.创建临时表空间
  1. 01.CREATE TEMPORARY TABLESPACE test_temp

  2. 02. TEMPFILE 'C:\oracle\product\10.1.0\oradata\orcl\test_temp01.dbf'

  3. 03. SIZE 64M

  4. 04. AUTOEXTEND ON

  5. 05. NEXT 32M MAXSIZE 2048M

  6. 06. EXTENT MANAGEMENT LOCAL;
  7. 复制代码
复制代码
5.创建用户

  1. 01.create user test identified test123

  2. 02.default tablespace test

  3. 03.temporary tablespace  test_temp;
  4. 复制代码
复制代码
6.授权
  1. 01.grant connect,resource to test;
  2. 复制代码7.杀死某个会话


  3. 01.Alter  system  kill session ‘sid,serial#’;
  4. 复制代码
复制代码
8.移动数据库位置
  1. 01.使表空间离线

  2. 02.alter tablespace test  offline;

  3. 03.移动数据库位置

  4. 04.修改控制文件

  5. 05.alter  tablespace  test

  6. 06.rename 'c:\test.dbf'  to ‘d:\test.dbf';

  7. 07.使数据库在线

  8. 08.alter tablespace  test  online
  9. 复制代码
复制代码
9.查看用户的默认表空间
  1. 01.select username,user_id,account_status,default_tablespace,TEMPORARY_TABLESP

  2. 02.from  dba_users

  3. 03.order by desc;
  4. 复制代码
复制代码
10.设置时间格式
  1. 01. alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
  2. 复制代码
复制代码

论坛徽章:
0
2 [报告]
发表于 2011-12-22 18:53 |只看该作者
学习鸟  谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP