This will only replicate the structure:
Mysql> CREATE Table a like mysql1; Query OK, 0 rows affected (0.03 sec) mysql> desc a;+----------+----------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+----------+----------+------+-----+---------+-------+| User | char (80) | NO | | | | | host | char (60) | NO | | | | | password | char (41) | NO | | | | +----------+----------+------+-----+---------+-------+3 rows in Set (0.00 sec) mysql> Select * from A; Empty Set (0.00 sec) mysql>
This will also copy the result set in addition to the copy structure:
Mysql> CREATE TABLE T8 select User,host from Mysql.user; Query OK, 1 row affected (0.03 sec) records:1 duplicates:0 warnings:0mysql> desc t8;+-------+----------+---- --+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------+----------+------+-----+---------+-------+| User | char (80) | NO | | | | | host | char (60) | NO | | | | +-------+----------+------+-----+---------+-------+2 rows in Set (0.01 sec) mysql> select * from t8;+------+--------- --+| user | Host |+------+-----------+| root | localhost |+------+-----------+1 row in Set (0.00 sec) mysql>
MySQL copy table structure/import data from results to a new table