从已有的表创建一个新的空表

CREATE TABLE new_table LIKE old_table;

注意: create table ... like 创建的表会保留原有表的字段、索引的定义,但不会保留外键的定义。

向空表插入数据

INSERT INTO new_table SELECT * FROM old_table;

 

参考链接:Create table in MySQL that matches another table? - Stack Overflow

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2021-10-22
  • 2021-09-14
  • 2021-07-04
  • 2022-01-08
猜你喜欢
  • 2021-07-05
  • 2022-01-23
  • 2021-10-18
  • 2021-12-27
  • 2022-02-12
  • 2022-12-23
  • 2022-02-05
相关资源
相似解决方案