我知道这句话:
create table xyz_new as select * from xyz;
它复制了结构和数据,但如果我只想要结构呢?
我知道这句话:
create table xyz_new as select * from xyz;
它复制了结构和数据,但如果我只想要结构呢?
当前回答
没有表数据的复制
create table <target_table> as select * from <source_table> where 1=2;
复制表数据
create table <target_table> as select * from <source_table>;
其他回答
没有表数据的复制
create table <target_table> as select * from <source_table> where 1=2;
复制表数据
create table <target_table> as select * from <source_table>;
简单地写一个查询:
create table new_table as select * from old_table where 1=2;
其中new_table是要创建的新表的名称,old_table是要复制其结构的现有表的名称,这将只复制结构。
你也可以做
create table abc_new as select * from abc;
然后截断表abc_new。希望这能满足你的要求。
创建表xyz_new作为select * from xyz;
——这将创建表并复制所有数据。
Delete from xyz_new;
-这将有相同的表结构,但所有复制的数据将被删除。
如果你想克服答案中指定的限制: 如何在不复制数据的情况下创建Oracle表的副本?
你可以这样做 创建表New_table为select * from Old_table 但是要小心 您创建的表不像old_table那样具有任何Index、PK等。