sql複製表結構和資料

2021-08-30 04:58:13 字數 664 閱讀 4754

sql server中使用select … into語句

按照使用場合可以分為以下幾類:

1. 實現全表備份:如:select * inot t1 from titles

2. 備份表的一部分列(不寫*而寫出列的列表)或一部分行(加where條件)

如: select title_id,title,price into t2 from titles—部分列

select * into t2 from titles whree price>10 –部分行

select title_id,title,price into t2 from titles whree price>10 –部分行和部分列

3. 只複製表的結構:如:select * inot t1 from titles where 1=2

select title_id,title,pub_name into t3

from titles t inner join publishers p

on t.pub_id=p.pub_id

oracle中使用create table … as select… 語句

實現的功能與sql server中基本相同,只是語法不同。例如:

create table dept_bak as select * from dept;

sql複製表結構和資料

功能 將查詢的結果放到乙個新錶中去,查詢結果可以 於乙個表或多個表 sqlserver中使用select into語句 按照使用場合可以分為以下幾類 1 實現全表備份 如 select inott1fromtitles 2 備份表的一部分列 不寫 而寫出列的列表 或一部分行 加where條件 如 s...

sql複製表結構和資料

功能 將查詢的結果放到乙個新錶中去,查詢結果可以 於乙個表或多個表 sqlserver中使用select into語句 按照使用場合可以分為以下幾類 1 實現全表備份 如 select inott1fromtitles 2 備份表的一部分列 不寫 而寫出列的列表 或一部分行 加where條件 如 s...

sql複製表結構和資料

功能 將查詢的結果放到乙個新錶中去,查詢結果可以 於乙個表或多個表 sql server中使用select into語句 按照使用場合可以分為以下幾類 1 實現全表備份 如 select inot t1 from titles 2 備份表的一部分列 不寫 而寫出列的列表 或一部分行 加where條件...