【问题标题】:how to copy a table without importing data and constraints in Oracle?如何在不导入数据和约束的情况下复制表?
【发布时间】:2015-01-26 11:47:10
【问题描述】:

我想从另一个名为 table1 的表创建一个名为 table2 的新表,而不导入数据和约束。我使用了这个查询:

create table2 as select * from table1 where 1=2;

这段代码在没有任何数据的情况下创建了table2,但从table1 导入了约束。有没有办法不从table1 导入约束?

【问题讨论】:

    标签: import oracle11g create-table


    【解决方案1】:

    答案可以在问题create table with select union has no constraints中找到。

    如果select是union,oracle是不会加任何约束的,所以直接用同一个select两次,第二次select一定不要包含任何记录:

    create table2 as 
    select * from table1 where 1=2
    union all
    select * from table1 where 1=2;
    

    【讨论】:

      猜你喜欢
      • 2013-12-31
      • 1970-01-01
      • 1970-01-01
      • 2013-02-22
      • 2015-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多