標籤:oracle 維護 巡檢 匯入匯出表 資料表空間使用率
Oracle資料庫中表的匯入匯出操作:
以Windows下的資料庫為例(用cmd方式):
匯出表:
1.匯出整個資料庫
exp 導表的使用者名稱/密碼@執行個體名 file=‘E:\xxx.dmp‘ full=y
2.匯出單表或多表
exp 導表的使用者名稱/密碼@執行個體名 file=‘E:\xxx.dmp‘ tables=t1[(t1,t2,t3)]
3.匯出資料庫中一個或多個使用者下的表
exp 導表的使用者名稱/密碼@執行個體名 file=‘E:\xxx.dmp‘ owner=(system,sys)
4.將資料庫中的表table1中的欄位filed1以"00"打頭的資料匯出
exp 導表的使用者名稱/密碼@執行個體名 file=‘E:\xxx.dmp‘ tables=(table1) query=\" where filed1 like ‘00%‘\"
------------------------------------------
匯入表:
將E:\xxx.dmp 中的資料匯入某資料庫中。
imp 導表的使用者名稱/密碼@執行個體名 file=e:\xxx.dmp
imp 導表的使用者名稱/密碼@執行個體名 full=y file=e:\xxx.dmp ignore=y
在後面加上 ignore=y 忽略匯入的報錯,直接匯入。
2 將e:\xxx.dmp中的表table1 匯入
imp 導表的使用者名稱/密碼@執行個體名 file=e:\xxx.dmp tables=(table1)
----------------------------
Linux的話直接exp,imp根據提示操作,效果也是一樣的。如果通過語句,可以現在emedit上寫好直接複製黏貼即可。
---------------------------
資料庫中查看版本:
select * from v$version;
Linux下查看ORACLE版本資訊:
file $ORACLE_HOME/bin/oracle
-------------------------
資料庫伺服器查看字元集:
select * from nls_database_parameters;
其中NLS_CHARACTERSET下面的就是該資料庫伺服器的字元集
-------------------------
查看錶空間xxx使用方式:
select /*+ ordered use_merge(a,b) */
a.tablespace_name 資料表空間名,
total/(1024*1024) 資料表空間大小,
(total-free)/(1024*1024) 資料表空間使用大小,
free/(1024*1024) 資料表空間剩餘大小,
round((total-free)/total,4)*100 "使用率%"
from (select tablespace_name,sum(bytes) free from dba_free_space
group by tablespace_name) a,
(select tablespace_name,sum(bytes) total from dba_data_files
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
and a.tablespace_name = ‘xxx‘;
-------------------------
查看當前角色XXX所具有的許可權:
select * from dba_sys_privs where grantee=‘XXX‘;
-------------------------
查看使用者為XXX的資料表空間配額。(-1為不受限制)
select tablespace_name,username,max_bytes from DBA_TS_QUOTAS where username=‘XXX‘;
-------------------------
設定使用者mc的資料表空間配額限為100M:
alter user mc quota 100M on tablespacname;
-------------------------
設定使用者mc的資料表空間配額為無限制:
alter user mc quota unlimited on tablespacname;
-------------------------
賦予使用者mc配置資料表空間無限額的許可權:
grant unlimited tablespace to mc;
-------------------------
本文出自 “刀寶” 部落格,請務必保留此出處http://mcluan.blog.51cto.com/11989648/1896263
Oracle日常巡檢維護中常用的一些STUFF