当前位置:操作系统 > Unix/Linux >>

数据库复制表结构

现在有一个数据库,我想用他的表结构,找了好久,比较好用的方法就是下面两种:
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 
即将启用约束条件... 
成功终止导入, 没有出现警告。

摘自 简约而不简单
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,