Oracle导出数据库结构的SQL
我想创建一个SQL脚本,可以重新创建我已经拥有的数据库.我想重新创建内部没有数据的数据库.
I want to create an sql script that can recreate a DB that I already have. I want to recreate the DB without data inside.
那么sqlplus是否可以导出用户的数据库?
So is there anyway with sqlplus of exporting a DB of a user?
有两种基本方法.
第一个是导出转储文件.可以使用Datapump实用程序:
The first is to export a dump file. This can be with the Datapump utility:
$ expdp apc/pw directory=data_dump_dir dumpfile=apc_20100707.dmp content=METADATA_ONLY
了解详情.
Datapump在Oracle10g中引入.在早期版本的数据库中,我们可以使用EXP实用程序执行相同的操作.
Datapump was introduced in Oracle10g. In earlier versions of the database we could use the EXP utility to do the same thing.
$ exp apc/pw dumpfile=apc_20100707.dmp rows=N
要导入文件,我们使用匹配的impdp
(或imp
)实用程序.
To import the file we use the matching impdp
(or imp
) utilities.
这是操作系统方法.为了生成实际的SQL脚本,我们可以使用Oracle 9i中引入的内置DBMS_METADATA包.这需要更多的工作,但是可以更好地控制导出对象的详细信息. 了解详情.
That is the OS approach. To generate actual SQL scripts we can use the built-in DBMS_METADATA package, introduced in Oracle 9i. This is a bit more work but offers much finer control over the details of the exported objects. Find out more.