oracl數據導入導出文檔

刪除表空間:
情況一:
1、表空間沒數據時
drop tablespace 表空間 including contents and datafiles;

情況二:
2、表空間有數據並且有blob字段時

先查出帶有blob字段的表名
SELECT * FROM DBA_TAB_COLUMNS WHERE DATA_TYPE LIKE '%LOB%' AND OWNER = '用戶登錄數據庫名'

批量刪除帶有blob字段表的刪除腳本
select 'drop table '||TABLE_NAME||';' FROM USER_TABLES WHERE TABLE_NAME LIKE 'T_%';
執行select 'drop table '||TABLE_NAME||';' FROM USER_TABLES WHERE TABLE_NAME LIKE 'T_%'查詢結果
例如:
drop table T_DATAQUALITY;
drop table TEST1;
drop table TEST2;
drop table TEST3;
drop table TB_REG_TAXPAYERSTAT_MV;
drop table TB_QUERY_TAXINFO_MV;
drop table T_ADDTAX;
drop table T_BALANALYSERES;
drop table T_BALVALIDATE;
drop table T_BUSINESSQRY;
drop table T_CASERISK;
drop table T_WAGELIST;
drop table T_WAGEITEMLIST;
drop table T_WAGEDEDUCTADJ;
drop table T_WAGE;
drop table T_VCHRES;
drop table T_READ;
drop table T_ITEMTHIRD_STR;
drop table T_ITEMTHIRD_NUM;
drop table T_ITEMTAX_STR;
drop table T_ITEMTAX_NUM;
drop table T_ITEMENT_STR;
drop table T_ITEMENT_NUM;
drop table T_FREQUENCYRES;
drop table T_COLLECT;
drop table T_BUSINESSQUERYLIST;
drop table T_BALCHECK;
drop table T_BALAGE;


最後刪除表空間
drop tablespace 表空間 including contents and datafiles;

情況三:
3、多張表空間內有關聯的表
select x.table_name,x.partition_name,x.tablespace_name table1,y.tablespace_name table2 from dba_tab_partitions x,dba_tab_partitions y where x.tablespace_name = 'A表空間名' and y.tablespace_name <> 'B表空間名' AND x.table_name=y.table_name

刪除
select x.table_name,x.partition_name,x.tablespace_name table1,y.tablespace_name table2 from dba_tab_partitions x,dba_tab_partitions y where x.tablespace_name = 'A表空間名' and y.tablespace_name <> 'B表空間名' AND x.table_name=y.table_name
查詢結果

最後刪除表空間
drop tablespace 表空間 including contents and datafiles;

--創建表空間

先創建E:\oradata\hngmp文件夾
然後創建表空間
create tablespace 表空間名
datafile 'E:\oradata\hngmp\表空間名.ora'
size 1G
autoextend on next 1G;

--刪除用戶
drop user 用戶登錄數據庫名 cascade;

--創建用戶
create user 用戶登錄數據庫密碼 identified by 用戶登錄數據庫名
default tablespace 主表空間名
temporary tablespace TEMP;


導入數據
impdp hngmp/[email protected]:1521/orcl directory=dpdir dum
pfile=hngmp_20190610.dp logfile=hngmp_sx schemas=hngmp transform=segment_attribu
tes:n exclude=statistics

導出數據
expdp hngmp/[email protected]:1521/ORCL directory=dpdir dumpfile=hngmp_20190610.dp logfile=hngmp_20190610.log schemas=hngmp  compression=all

其他導入數據語句
impdp gmp/[email protected]:1521/dqyss directory=DMPDIR dumpfile=2017051101.dp logfile=20170511.log FULL = Y

impdp hngmp/[email protected]:1521/orcl directory=dpdir dumpfile=20190424.dmp logfile=hngmp_20190514_02.log table_exists_action=replace remap_schema=gmpsxds:hngmp schemas=hngmp

impdp hngmp/[email protected]:1521/orcl directory=dpdir dumpfile=20190424.dmp logfile=hngmp_20190513.log table_exists_action=replace remap_schema=gmp:hngmp schemas=hngmp

impdp sjgl/[email protected]:1521/orcl directory=dpdir dumpfile=sjgl_20190515.dmp logfile=sjgl_20190515.log table_exists_action=replace remap_schema=gmp:hngmp schemas=hngmp

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章