Chinaunix

标题: [oracle] oracle工作中常用命令 [打印本页]

作者: 三里屯摇滚    时间: 2011-12-10 22:05
标题: [oracle] oracle工作中常用命令
[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. 复制代码
复制代码

作者: 小忻黑夜    时间: 2011-12-22 18:53
学习鸟  谢谢分享




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2