Home > Database > Mysql Tutorial > 表数据复制语句_MySQL

表数据复制语句_MySQL

WBOY
Release: 2016-05-30 17:11:03
Original
1252 people have browsed it

这里有两种表数据复制语句:

 

1. INSERT INTO SELECT语句

 

语句形式为:INSERT INTO table2(field1, field2, ...) SELECT value1, value2, ... FROM table1

 

要求:目标表table2必须存在

 

这里由于目标表table2已经存在,所以我们除了插入源表table1的字段外,还可以插入常量

 

2. SELECT INTO FROM语句

 

语句形式为:SELECT vale1, value2 INTO table2 FROM table1

 

要求:目标表table2不存在

 

这里在插入时会自动创建表table2,并将table1中指定字段数据复制到table2中

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template