我知道这句话:
create table xyz_new as select * from xyz;
它复制了结构和数据,但如果我只想要结构呢?
我知道这句话:
create table xyz_new as select * from xyz;
它复制了结构和数据,但如果我只想要结构呢?
当前回答
你可以这样做 创建表New_table为select * from Old_table 但是要小心 您创建的表不像old_table那样具有任何Index、PK等。
其他回答
使用pl/sql开发器,你可以在sql工作区或对象资源管理器中右键单击table_name,然后单击“查看”,然后单击“查看sql”,它会生成sql脚本来创建包含所有约束、索引、分区等的表。
接下来使用new_table_name运行脚本
简单地写一个查询:
create table new_table as select * from old_table where 1=2;
其中new_table是要创建的新表的名称,old_table是要复制其结构的现有表的名称,这将只复制结构。
create table xyz_new as select * from xyz where rownum = -1;
避免反复迭代,并在1=2的条件下不插入任何内容
没有表数据的复制
create table <target_table> as select * from <source_table> where 1=2;
复制表数据
create table <target_table> as select * from <source_table>;
使用sql developer选择表并单击DDL选项卡
在sql工作表中运行该代码时,可以使用该代码创建没有数据的新表
Sqldeveloper是oracle提供的一个免费应用程序。
如果表有序列或触发器,ddl有时也会为您生成这些。你只需要注意它们的顺序,知道什么时候打开或关闭触发器。