dushaoshuai / dushaoshuai.github.io

https://www.shuai.host
0 stars 0 forks source link

MySQL :: Copy Table #25

Open dushaoshuai opened 2 years ago

dushaoshuai commented 2 years ago

1

CREATE TABLE `tb` SELECT * FROM `ta`;

OR

-- https://dev.mysql.com/doc/refman/8.0/en/create-table-select.html#:~:text=%2D%2D%2B-,mysql%3E,-CREATE%20TABLE%20tt1
CREATE TABLE `tb` TABLE `ta`;

2

13.2.6.1 INSERT ... SELECT Statement

CREATE TABLE `tb` LIKE `ta`;
INSERT INTO `tb` SELECT * FROM `ta`; -- Or beginning with MySQL 8.0.19: INSERT INTO `tb` TABLE `ta`;