SyntaxHighlighter

2013-05-14

Clone records in SQL

使用SQL文重複複製表格內容

以下手法可用於MySQL
並可以使用於任何有自動增加值(AutoIncrease)的表格

CREATE TEMPORARY TABLE temp_table ENGINE=MEMORY SELECT * FROM your_table WHERE id=1;

UPDATE temp_table SET id=NULL; /* Update other values at will. */

INSERT INTO your_table SELECT * FROM temp_table;
DROP TABLE temp_table;


在Access裡,你可以用SELECT INTO標準句來替換
SELECT * INTO temp_table FROM your_table WHERE id=1 ;

UPDATE temp_table SET id=NULL; /* Update other values at will. */

INSERT INTO your_table SELECT * FROM temp_table;

DROP TABLE temp_table;

以上

0 件のコメント:

人気の投稿