Heim > Datenbank > MySQL-Tutorial > MySQL数据库中拷贝数据表的方法

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Freigeben: 2016-06-07 16:20:54
Original
1324 Leute haben es durchsucht

在 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'

  )

Verwandte Etiketten:
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Aktuelle Ausgaben
So ändern Sie MySQL in MySQL
Aus 1970-01-01 08:00:00
0
0
0
MySQL-Startfehler unter Centos
Aus 1970-01-01 08:00:00
0
0
0
MySQL stoppt den Prozess
Aus 1970-01-01 08:00:00
0
0
0
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage