歡迎您光臨本站 註冊首頁

[oracle] oracle工作中常用命令

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

[oracle] oracle工作中常用命令

oracle工作中常用命令


工作中經常用的一些命令記錄下來。慢慢更新,自己做個備份。。。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,

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

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

04.where a.tablespace_name=b.tablespace_name and

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

06.order by tablespace_name desc ;
複製代碼2.查看lock
01.select b.username,b.sid,b.serial#,b.logon_time,b.osuser

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

03.where a.session_id = b.sid order by b.logon_time;
複製代碼3.創建表空間
01.create tablespace test

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

03.autoextend on  next 64m;
複製代碼4.創建臨時表空間01.CREATE TEMPORARY TABLESPACE test_temp

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

03. SIZE 64M

04. AUTOEXTEND ON

05. NEXT 32M MAXSIZE 2048M

06. EXTENT MANAGEMENT LOCAL;
複製代碼5.創建用戶
01.create user test identified test123

02.default tablespace test

03.temporary tablespace  test_temp;
複製代碼6.授權01.grant connect,resource to test;
複製代碼7.殺死某個會話


01.Alter  system  kill session 『sid,serial#』;
複製代碼8.移動資料庫位置01.使表空間離線

02.alter tablespace test  offline;

03.移動資料庫位置

04.修改控制文件

05.alter  tablespace  test

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

07.使資料庫在線

08.alter tablespace  test  online
複製代碼9.查看用戶的默認表空間01.select username,user_id,account_status,default_tablespace,TEMPORARY_TABLESP

02.from  dba_users

03.order by desc;
複製代碼10.設置時間格式01. alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
複製代碼
《解決方案》

學習鳥  謝謝分享

[火星人 ] [oracle] oracle工作中常用命令已經有1184次圍觀

http://coctec.com/docs/service/show-post-1410.html