我知道这句话:
create table xyz_new as select * from xyz;
它复制了结构和数据,但如果我只想要结构呢?
我知道这句话:
create table xyz_new as select * from xyz;
它复制了结构和数据,但如果我只想要结构呢?
当前回答
你也可以做
create table abc_new as select * from abc;
然后截断表abc_new。希望这能满足你的要求。
其他回答
没有表数据的复制
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;
Source_table是你要复制其结构的表。
你可以这样做 创建表New_table为select * from Old_table 但是要小心 您创建的表不像old_table那样具有任何Index、PK等。
通过其他方式,您可以从下面列出的命令获取表创建的ddl,并执行创建。
SELECT DBMS_METADATA.GET_DDL('TYPE','OBJECT_NAME','DATA_BASE_USER') TEXT FROM DUAL
类型是表,程序等。
使用这个命令,您可以从数据库对象中获得大部分ddl。
你也可以做
create table abc_new as select * from abc;
然后截断表abc_new。希望这能满足你的要求。