当前位置:首页 > PHP教程 > PHP总结归纳

MySQL数据库中拷贝数据表的方法

在 mysql 中拷贝表,将 old_table 表拷贝为 new_table 表。 1. 不拷贝表数据,只拷贝结构。 create table new_table like old_table 2. 通过 select 查询来拷贝,new_table 表会丢失主键、索引等信息。 引用 create table new_table as ( select * from old_

  在 mysql 中拷贝表,将 old_table 表拷贝为 new_table 表。

  1. 不拷贝表数据,只拷贝结构。

  create table new_table like old_table

  2. 通过 select 查询来拷贝,,new_table 表会丢失主键、索引等信息。

  引用

  create table new_table as

  (

  select *

  from old_table

  )

  3. 完全拷贝表

  create table new_table like old_table;

  insert into new_table select * from old_table;

  4. 仅拷贝字段

  create table new_table as

  (

  select field1, field2 from old_table

  )

  5. 部分拷贝

  create table new_table as

  (

  select * from old_table where field1 = 'mangguo'

  )

.syntaxhighlighter{padding-top:20px;padding-bottom:20px;}
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!