数据库操作之复制表结构方法

来源:互联网 发布:linux tomcat配置 编辑:程序博客网 时间:2024/06/06 06:43

Oracle数据库和MSSql的数据库表结构复制差距非常大:

 

Oracle:

create table target_table_name

as

select column_name[,....n] from source_tableName

MSSQL:

select column_name[,....n] into target_table_name from source_tableName

如果为全部列,则可以用 * 代替.

注意如果后面不跟条件,那么则是复制表结构以及所有数据。

如果只是为了复制结构可以跟上一个条件(只要条件查询不出数据即可)

 

 

例子:

 

假如Oracle数据库和MSSQL都有表

create table t_user

{

       c_id char(10) not null,

       c_name varchar(30) not null,

       c_sex     char(1) not null,

       c_note   varchar(255) null

}

Oracle操作:

create table t_user_bak

as

select * from t_user;

 

MSSQL操作:

select * into t_user_bak from t_user

go