您的位置:首页 > 数据库

数据库复制表结构

2012-02-20 19:04 239 查看
现在有一个数据库,我想用他的表结构,找了好久,比较好用的方法就是下面两种:

1、

create table a as select * from b where 1=2 ;

2、

--导出
exp userid=用户名/密码 file=文件名.dmp tables=(表名1,表名2.....) rows=n;
--导入
imp userid=用户名/密码 file=文件名.dmp full=y;

---
C:\Documents and Settings\Administrator>exp userid=scott/tiger file=scott.dmp tables=(emp,dept) rows=n;

Export: Release 10.2.0.1.0 - Production on 星期三 8月 3 18:31:48 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
注: 将不导出表数据 (行)

即将导出指定的表通过常规路径...
. . 正在导出表                             EMP
. . 正在导出表                            DEPT
成功终止导出, 没有出现警告。

C:\Documents and Settings\Administrator>imp userid=test/test file=scott.dmp full=y;

Import: Release 10.2.0.1.0 - Production on 星期三 8月 3 18:42:36 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

经由常规路径由 EXPORT:V10.02.01 创建的导出文件

警告: 这些对象由 SCOTT 导出, 而不是当前用户

已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
. 正在将 SCOTT 的对象导入到 TEST
. 正在将 SCOTT 的对象导入到 TEST
即将启用约束条件...
成功终止导入, 没有出现警告。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: