国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

MySQL truncate table語句的使用

瀏覽:7日期:2023-10-05 07:09:20

Truncate table語句用來刪除/截斷表里的所有數據

和delete刪除所有表數據在邏輯上含義相同,但性能更快 類似執行了drop table和create table兩個語句

mysql> select * from students_bak;+-----+----------+--------+---------+| sid | sname | gender | dept_id |+-----+----------+--------+---------+| 101 | zhangsan | male | 10 || 1 | aa | 1 | 1 |+-----+----------+--------+---------+2 rows in set (0.00 sec)mysql> truncate table students_bak;Query OK, 0 rows affected (0.16 sec)mysql> select * from students_bak;Empty set (0.00 sec)mysql> set autocommit=off;Query OK, 0 rows affected (0.01 sec)mysql> select * from students3;+-----+-------+--------+---------+--------+| sid | sname | gender | dept_id | sname2 |+-----+-------+--------+---------+--------+| 100 | NULL | 1 | 1 | NULL |+-----+-------+--------+---------+--------+1 row in set (0.01 sec)mysql> truncate table students3;Query OK, 0 rows affected (0.06 sec)mysql> rollback;Query OK, 0 rows affected (0.00 sec)mysql> select * from students3;Empty set (0.00 sec)mysql> delete from students;Query OK, 5 rows affected (0.00 sec)mysql> select * from students;Empty set (0.00 sec)mysql> rollback;Query OK, 0 rows affected (0.07 sec)mysql> select * from students;+-----+-------+--------+---------+| sid | sname | gender | dept_id |+-----+-------+--------+---------+| 1 | aa | 3 | 1 || 4 | cc | 3 | 1 || 5 | dd | 1 | 2 || 6 | aac | 1 | 1 || 10 | a | 1 | 1 |+-----+-------+--------+---------+5 rows in set (0.00 sec)

到此這篇關于MySQL truncate table語句的使用的文章就介紹到這了,更多相關MySQL truncate table內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: MySQL 數據庫
相關文章:
主站蜘蛛池模板: 大余县| 嘉善县| 体育| 利川市| 汾阳市| 化隆| 西贡区| 柳河县| 乌鲁木齐县| 饶河县| 华安县| 周至县| 泰来县| 海兴县| 吐鲁番市| 德令哈市| 迁西县| 佛学| 和顺县| 济南市| 雷山县| 淄博市| 金沙县| 周至县| 甘肃省| 丹寨县| 凤庆县| 临高县| 印江| 滁州市| 泌阳县| 阿克| 裕民县| 汨罗市| 逊克县| 岳普湖县| 朝阳市| 元谋县| 桦南县| 商洛市| 綦江县|