12c 資料泵提取建表空間語句和建表語句
資料泵含有很多靈活的功能,比如使用expdp匯出用於重建表空間的DDL語句,或者建表的DDL語句。
使用expdp匯出建立表空間的後設資料,其中引數include會限制匯出範圍為表空間
[oracle@snow ~]$ expdp dp/dp directory=dp_dir dumpfile=ex.dmp full=y include=tablespace
Export: Release 12.1.0.1.0 - Production on Mon Feb 9 13:24:18 2015
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Starting "DP"."SYS_EXPORT_FULL_01": dp/******** directory=dp_dir dumpfile=ex.dmp full=y include=tablespace
Estimate in progress using BLOCKS method...
Total estimation using BLOCKS method: 0 KB
Processing object type DATABASE_EXPORT/TABLESPACE
Master table "DP"."SYS_EXPORT_FULL_01" successfully loaded/unloaded
******************************************************************************
Dump file set for DP.SYS_EXPORT_FULL_01 is:
/home/oracle/ex.dmp
Job "DP"."SYS_EXPORT_FULL_01" successfully completed at Mon Feb 9 13:24:24 2015 elapsed 0 00:00:04
使用impdp工具生成建立表空間的sql語句,sqlfile引數定義了儲存sql語句指令碼的名稱為tbsp.sql
這個impdp語句看上去會有些困惑,但它不會像資料庫匯入任何資料,只是生成一個sql指令碼而已。
[oracle@snow ~]$ impdp dp/dp directory=dp_dir dumpfile=ex.dmp sqlfile=tbsp.sql
Import: Release 12.1.0.1.0 - Production on Mon Feb 9 13:27:31 2015
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "DP"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
Starting "DP"."SYS_SQL_FILE_FULL_01": dp/******** directory=dp_dir dumpfile=ex.dmp sqlfile=tbsp.sql
Processing object type DATABASE_EXPORT/TABLESPACE
Job "DP"."SYS_SQL_FILE_FULL_01" successfully completed at Mon Feb 9 13:27:33 2015 elapsed 0 00:00:01
看看生成的sql語句全貌
[oracle@snow ~]$ more tbsp.sql
-- CONNECT DP
ALTER SESSION SET EVENTS '10150 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10904 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '25475 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10407 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10851 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '22830 TRACE NAME CONTEXT FOREVER, LEVEL 192 ';
-- new object type path: DATABASE_EXPORT/TABLESPACE
CREATE UNDO TABLESPACE "UNDOTBS1" DATAFILE
'/u01/app/oracle/oradata/ora12c/undotbs01.dbf' SIZE 26214400
AUTOEXTEND ON NEXT 5242880 MAXSIZE 32767M
BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE;
ALTER DATABASE DATAFILE
'/u01/app/oracle/oradata/ora12c/undotbs01.dbf' RESIZE 183500800;
CREATE TEMPORARY TABLESPACE "TEMP" TEMPFILE
'/u01/app/oracle/oradata/ora12c/temp01.dbf' SIZE 92274688
AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1048576;
CREATE TABLESPACE "USERS" DATAFILE
'/u01/app/oracle/oradata/ora12c/users01.dbf' SIZE 5242880
AUTOEXTEND ON NEXT 1310720 MAXSIZE 32767M
LOGGING ONLINE PERMANENT BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT
NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO;
ALTER DATABASE DATAFILE
'/u01/app/oracle/oradata/ora12c/users01.dbf' RESIZE 11796480;
CREATE TABLESPACE "EXAMPLE" DATAFILE
'/u01/app/oracle/oradata/ora12c/example01.dbf' SIZE 104857600
AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M
NOLOGGING ONLINE PERMANENT BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT
NOCOMPRESS SEGMENT SPACE MANAGEMENT AUTO;
ALTER DATABASE DATAFILE
'/u01/app/oracle/oradata/ora12c/example01.dbf' RESIZE 338821120;
下面的例子是使用資料泵提取建表語句,注意引數content=metadata_only
[oracle@snow ~]$ expdp dp/dp directory=dp_dir dumpfile=tab.dmp full=y include=table content=metadata_only
[oracle@snow ~]$ impdp dp/dp directory=dp_dir dumpfile=tab.dmp sqlfile=tabs.sql
[oracle@snow ~]$ more tabs.sql
-- CONNECT DP
ALTER SESSION SET EVENTS '10150 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10904 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '25475 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10407 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10851 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '22830 TRACE NAME CONTEXT FOREVER, LEVEL 192 ';
-- new object type path: DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE
CREATE TABLE "SYS"."KU$_USER_MAPPING_VIEW"
( "USER#" NUMBER NOT NULL ENABLE,
"NAME" VARCHAR2(128 BYTE) NOT NULL ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "SYSAUX" ;
...
全文完
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29047826/viewspace-1441621/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 資料庫-單表結構-建表語句資料庫
- 多表查詢建表語句
- MySQL檢視建表語句MySql
- MySQL高階部分-建表語句MySql
- idea內建資料庫 + sql語句庫表操作Idea資料庫SQL
- sybase iq表空間管理常用語句
- mysql中建庫、建表、增刪改查DDL語句MySql
- excel表結構生成powerDesigner模型,生成建表語句sqlExcel模型SQL
- PostgreSQL:所有支援的資料型別及建表語句例項SQL資料型別
- PostgreSQL獲取建表語句儲存過程SQL儲存過程
- 利用MySQL原資料資訊批量轉換指定庫資料表生成Hive建表語句MySqlHive
- 【Oracle】scott使用者下表結構、初始化資料和建表語句Oracle
- 複製表結構和資料SQL語句SQL
- mysql建表常用sql語句個人經驗分享MySql
- 通過實體類生成 mysql 的建表語句MySql
- oracle匯出使用者、表空間和角色的建立語句Oracle
- SQL server資料庫表碎片比例查詢語句SQLServer資料庫
- Oracle 批量建表空間Oracle
- 1.4 資料庫和常用SQL語句(正文)——MySQL資料庫命令和SQL語句資料庫MySql
- 分支語句和迴圈語句
- DM7聯機執行SQL語句進行表空間備份SQL
- ORACLE 資料庫 查詢語句與DML語句Oracle資料庫
- oracle資料庫檢視鎖表的sql語句整理Oracle資料庫SQL
- DBeave如何檢視資料庫表的DDL建立語句資料庫
- 阿里JAVA手冊之MySQL資料庫(建表規約、索引規約、SQL語句、ORM對映)阿里JavaMySql資料庫索引ORM
- flask之控制語句 if 語句與for語句Flask
- 迴圈語句+資料型別的內建方法(數字,字串)資料型別字串
- 兩表聯查修改的sql語句SQL
- 【SCRIPT】Oracle表管理段管理常用語句Oracle
- SQL單表查詢語句總結SQL
- 定時生成分月表sql語句SQL
- 統計報表 -- sql統計語句SQL
- 資料庫操作語句資料庫
- 【資料庫】SQL語句資料庫SQL
- Python-條件語句和迴圈語句Python
- Linux下邏輯測試語句引數和流程控制語句 if語句Linux
- 使用SQL語句將資料庫中的兩個表合併成一張表SQL資料庫
- Mysql 獲取表設計查詢語句MySql
- SQLite語句(一):表的操作和約束SQLite