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 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" ;