当前位置:   article > 正文

MySQL--备份表操作,简单易懂!_mysql创建备份表

mysql创建备份表

原理:将一个查询结果当做一张表进行新建!

以此完成表的快速复制

表创建出来的同时,表中的数据也有了

  1. mysql> select * from s_user;
  2. +------+----------+------------+---------------------+
  3. | id | name | birth | create_time |
  4. +------+----------+------------+---------------------+
  5. | 1 | zhangsan | 1990-10-01 | 2023-09-29 23:41:55 |
  6. | 2 | w1 | 1990-10-02 | 2023-10-05 23:46:08 |
  7. | 3 | w2 | 1990-10-03 | 2023-10-05 23:46:08 |
  8. | 4 | w3 | 1990-10-04 | 2023-10-05 23:46:08 |
  9. +------+----------+------------+---------------------+
  10. 4 rows in set (0.01 sec)
  11. mysql> create table s_user2 as select * from s_user;
  12. Query OK, 4 rows affected (0.01 sec)
  13. Records: 4 Duplicates: 0 Warnings: 0
  14. mysql> select * from s_user2;
  15. +------+----------+------------+---------------------+
  16. | id | name | birth | create_time |
  17. +------+----------+------------+---------------------+
  18. | 1 | zhangsan | 1990-10-01 | 2023-09-29 23:41:55 |
  19. | 2 | w1 | 1990-10-02 | 2023-10-05 23:46:08 |
  20. | 3 | w2 | 1990-10-03 | 2023-10-05 23:46:08 |
  21. | 4 | w3 | 1990-10-04 | 2023-10-05 23:46:08 |
  22. +------+----------+------------+---------------------+
  23. 4 rows in set (0.00 sec)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/410354
推荐阅读
相关标签
  

闽ICP备14008679号