問(wèn)題
要?jiǎng)?chuàng)建新表, 該表與已有表的列設(shè)置相同. 例如, 想要一個(gè)dept表的副本, 名未dept_2, 淡只是想復(fù)制表結(jié)構(gòu)而不想復(fù)制源表中的記錄.
解決方案
DB2
使用帶有l(wèi)ike子句的create table命令:
create table dept_2 like dept
Oracle, MySQL 和 PostgreSQL
在create table命令中, 使用一個(gè)不返回任何行的子查詢:
create table dept_2
as
select * from dept where 1=0
SQL Server
使用帶有不返回任何行的查詢和into子句:
select * into dept_2 from dept where 1=0