oracle通过dmp⽂件获取建表,建⽤户语句
oracle可以通过impdp命令⼯具获取建⽤户和建表的语句。impdp指定参数sqlfile可以解析dmp⽂件。
数据导出命令⾏:
[oracle@node01 ~]$ expdp \' / as sysdba\' directory=dmpdir dumpfile=expdptest.dmp schemas=test logfile=expdptest.log
解析导出的dmp⽂件:
[oracle@node01 ~]$ impdp \'/ as sysdba\' directory=dmpdir dumpfile=expdptest.dmp sqlfile=expdptest.sql
这样就可以查看建⽤户,建表语句:
[oracle@node01 ~]$ cat expdptest.sql
-- CONNECT SYS
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: SCHEMA_EXPORT/USER
-- CONNECT SYSTEM
CREATE USER "TEST" IDENTIFIED BY VALUES 'S:BF976574B1327B4A16FA8A5646627B09E4CB07FEAF9CCFE4F7806FB73399;48724AE7C369325F'
DEFAULT TABLESPACE "TEST"
TEMPORARY TABLESPACE "TEMP";
-- new object type path: SCHEMA_EXPORT/SYSTEM_GRANT
oracle登录命令GRANT UNLIMITED TABLESPACE TO "TEST";
-- new object type path: SCHEMA_EXPORT/ROLE_GRANT
GRANT "CONNECT" TO "TEST";
GRANT "RESOURCE" TO "TEST";
-- new object type path: SCHEMA_EXPORT/DEFAULT_ROLE
ALTER USER "TEST" DEFAULT ROLE ALL;
-- new object type path: SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
-- CONNECT TEST
BEGIN
sys.dbms_logrep_imp.instantiate_schema(schema_name=>SYS_CONTEXT('USERENV','CURRENT_SCHEMA'), export_db_name=>'ORCL', inst_scn=>'1543220'); COMMIT;
END;
/
-- new object type path: SCHEMA_EXPORT/TABLE/TABLE
-- CONNECT SYS
CREATE TABLE "TEST"."TEST"
(    "ID" NUMBER(*,0)
) SEGMENT CREATION IMMEDIATE
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 "TEST" ;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。