开发者

sql for copying a table

开发者 https://www.devze.com 2023-01-30 04:51 出处:网络
I have a table \'table1\' in\'database1\'. Now i wants to create a ta开发者_运维问答ble \'table2\' in \'database2\', with the exact data from \'table1\'

I have a table 'table1' in 'database1'.

Now i wants to create a ta开发者_运维问答ble 'table2' in 'database2', with the exact data from 'table1'

How can i do that with select into query


SELECT * INTO table2 IN database2 FROM table1


You don't mention your SQL dialect, but this is how you would do it on SQL Server:

SELECT *
INTO   database2..table2
FROM   database1..table1


You won't use a select into, that's for setting variables (with mysql anyway).

create table table2 as
select * from table1

Note that this doesn't copy indexes or anything, and the typical lecture about having a bad schema.

0

精彩评论

暂无评论...
验证码 换一张
取 消