MySQL basic learning _ lesson 013 _ table replication and batch insertion

1, the copy of the table

Syntax format:

CREATE TABLE 表名 AS SELECT 语句;

It means that the query result of the following select is used as a new table to be copied and created

Example 1: Copy all fields of the query result

Create a new table called t_testtable_001, this table is created by copying the query result of the following select * from t_testtable as a table,

Among them: t_testtable This table is detailed in lesson 011: https://blog.csdn.net/weixin_43184774/article/details/115085959

create table t_testtable_001 as select * from t_testtable;

Example 2: Copy some fields of the query result

Create a new table t_testtable_002, this new table is composed of the following t_testtable table, according to the name, classno, birth field copy

Among them: t_testtable This table is detailed in lesson 011: https://blog.csdn.net/weixin_43184774/article/details/115085959

create table t_testtable_002 as select name,classno,birth from t_testtable;

2, the insertion of the table

Example: Put the query result in and out of a new table

Insert the query result of select * from t_testtable into the t_testtable_001 table

insert into t_testtable_001 select * from t_testtable;

Guess you like

Origin blog.csdn.net/weixin_43184774/article/details/115176140