赞
踩
原理:将一个查询结果当做一张表进行新建!
以此完成表的快速复制
表创建出来的同时,表中的数据也有了
- mysql> select * from s_user;
- +------+----------+------------+---------------------+
- | id | name | birth | create_time |
- +------+----------+------------+---------------------+
- | 1 | zhangsan | 1990-10-01 | 2023-09-29 23:41:55 |
- | 2 | w1 | 1990-10-02 | 2023-10-05 23:46:08 |
- | 3 | w2 | 1990-10-03 | 2023-10-05 23:46:08 |
- | 4 | w3 | 1990-10-04 | 2023-10-05 23:46:08 |
- +------+----------+------------+---------------------+
- 4 rows in set (0.01 sec)
-
- mysql> create table s_user2 as select * from s_user;
- Query OK, 4 rows affected (0.01 sec)
- Records: 4 Duplicates: 0 Warnings: 0
-
- mysql> select * from s_user2;
- +------+----------+------------+---------------------+
- | id | name | birth | create_time |
- +------+----------+------------+---------------------+
- | 1 | zhangsan | 1990-10-01 | 2023-09-29 23:41:55 |
- | 2 | w1 | 1990-10-02 | 2023-10-05 23:46:08 |
- | 3 | w2 | 1990-10-03 | 2023-10-05 23:46:08 |
- | 4 | w3 | 1990-10-04 | 2023-10-05 23:46:08 |
- +------+----------+------------+---------------------+
- 4 rows in set (0.00 sec)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。