我是一個java開發者,我的文章,沒有華麗的言辭,沒有666的版式,這些都是我自己工作中用到的解決方案,很多都是直接粘貼的源碼,在這裡與君分享。如果喜歡這裡文章可以關注我,我回繼續發的,謝謝你。
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5yMxQDOlFTN5EWYiRWOyQzN5QmY0IjY1kzY1ImM0QTZh9CX0JXZ252bj91Ztl2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
說明:條件1=1肯定成立,表示備份資料和表結構,1=2則不成立,隻備份表結構
1.Sql Server
select * into newtableName from oldTableName Where 1=1; 備份表結構和資料
select * into newtableName from oldTableName Where 1=2; 備份表結構
2. Oracle 3種方法
create table newTableName as select * from oldTableName where 1=1;備份表和資料
select * into newtableName from oldTableName Where 1=1; 備份表和資料
insert into newtableName select * from oldTableName Where 1=1; 備份表和資料
3.Mysql
create table newTableName as select * from oldTableName where 1=1;備份表和資料