How to copy data from one tabe to a new table.
Shows how to create new the same table and copy data.
1 2 3 4 5 6 7 8 9 10 |
<pre><code>CREATE TABLE table_a ( id INT(11) DEFAULT NULL, column_a INT(11) DEFAULT NULL ); INSERT INTO table_a VALUES (1, 10), (2, 20), (3, 30), (4, NULL), (5, 0); |
Create and copy data:
1 |
<pre><code>CREATE TABLE table_b SELECT * FROM table_a; |
Check results:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<pre><code>SHOW CREATE TABLE table_b; > CREATE TABLE `table_b` ( `id` int(11) DEFAULT NULL, `column_a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT * FROM table_b; +------+----------+ | id | column_a | +------+----------+ | 1 | 10 | | 2 | 20 | | 3 | 30 | | 4 | NULL | | 5 | 0 | +------+----------+ |