henplus> select * into database_name.new_table from old_table; affected 47186 rows (547 msec) //成功
這麼簡單就搞定建table及放入所有資料。
不過官網文字有個注意事項
WARNING! Be careful about running select into across databases if you have column names that exist in both databases, as this may cause problems.
另外,以官網Back Up Data to a New Table所記載,最好是先用sp_spaceused查詢下資料庫或資料表的使用空間,不過使用henplus只會看到如下的回覆文字,得使用DbVisualizer或其他方式吧,有發現再做更新。
sp_spaceused old_table;
affected 1 rows (50 msec)
注意事項:做這之前要先設定auto-commit為on,否則會一直出現FAILURE: The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'xxxx' database.
henplus>set-session-property auto-commit on;
參考網址:
Back Up Data to a New Table
SQL SELECT INTO 语句
沒有留言:
張貼留言