Create table (structure) from existing table

后端 未结 15 1409
遇见更好的自我
遇见更好的自我 2020-11-27 13:46

How to create new table which structure should be same as another table

I tried

CREATE TABLE dom AS SELECT * FROM dom1 WHERE 1=2

bu

15条回答
  •  一生所求
    2020-11-27 13:52

    Copy structure only (copy all the columns)

    Select Top 0 * into NewTable from OldTable
    

    Copy structure only (copy some columns)

    Select Top 0 Col1,Col2,Col3,Col4,Col5 into NewTable from OldTable
    

    Copy structure with data

    Select * into NewTable from OldTable
    

    If you already have a table with same structure and you just want to copy data then use this

    Insert into NewTable Select * from OldTable
    

提交回复
热议问题