mysql 复制表结构 / 从结果中导入数据到新表
Posted FireC@t @ Perl6
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 复制表结构 / 从结果中导入数据到新表相关的知识,希望对你有一定的参考价值。
这只会复制结构:
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>
这除了复制结构, 还会复制结果集:
mysql> create table t8 select user,host from mysql.user; Query OK, 1 row affected (0.03 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> 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 复制表结构 / 从结果中导入数据到新表的主要内容,如果未能解决你的问题,请参考以下文章