MySQL truncate table語句的使用
Truncate table語句用來刪除/截?cái)啾砝锏乃袛?shù)據(jù)
和delete刪除所有表數(shù)據(jù)在邏輯上含義相同,但性能更快 類似執(zhí)行了drop table和create table兩個(gè)語句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)
到此這篇關(guān)于MySQL truncate table語句的使用的文章就介紹到這了,更多相關(guān)MySQL truncate table內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. Access數(shù)據(jù)庫安全的幾個(gè)問題2. MySQL存儲(chǔ)過程例子(包含事務(wù)、參數(shù)、嵌套調(diào)用、游標(biāo)循環(huán)等)3. oracle數(shù)據(jù)庫id自增及生成uuid問題4. mysql-bin.000001文件的來源及處理方法5. sqlserver數(shù)據(jù)庫導(dǎo)入方法的詳細(xì)圖文教程6. MySQL雙主(主主)架構(gòu)配置方案7. MySQL 的啟動(dòng)選項(xiàng)和系統(tǒng)變量實(shí)例詳解8. Oracle中SPFILE文件特點(diǎn)及其具體操作9. Oracle的PDB數(shù)據(jù)庫創(chuàng)建DIRECTORY時(shí)遇到ORA-65254問題及解決方法10. 如何遠(yuǎn)程調(diào)用ACCESS數(shù)據(jù)庫
