首页 > 代码库 > mysql 复制表结构 / 从结果中导入数据到新表
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 复制表结构 / 从结果中导入数据到新表
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。