濮阳杆衣贸易有限公司

主頁 > 知識庫 > MySQL truncate table語句的使用

MySQL truncate table語句的使用

熱門標簽:電話外呼系統(tǒng)改號 地圖標注費用是多少 怎樣在地圖標注銷售區(qū)域 南昌三維地圖標注 啥是企業(yè)400電話辦理 曲靖移動外呼系統(tǒng)公司 百應電話機器人優(yōu)勢 外呼系統(tǒng)打電話上限是多少 武漢網(wǎng)絡外呼系統(tǒng)服務商

Truncate table語句用來刪除/截斷表里的所有數(shù)據(jù)

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

執(zhí)行代碼

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)

truncate需要什么權限

truncate的執(zhí)行是先drop后create的, 所以truncate包含drop和create,是一個復合的動作, 對于create不用賦予, 所以只需要賦予drop權限就可以了

到此這篇關于MySQL truncate table語句的使用的文章就介紹到這了,更多相關MySQL truncate table內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • MYSQL中Truncate的用法詳解
  • MySQL用truncate命令快速清空一個數(shù)據(jù)庫中的所有表
  • MySQL Truncate用法詳解
  • MySQL中truncate誤操作后的數(shù)據(jù)恢復案例
  • mysql 刪除操作(delete+TRUNCATE)
  • MySQL刪除數(shù)據(jù)Delete與Truncate語句使用比較

標簽:荊州 資陽 甘南 滄州 黑河 錦州 吉林 隨州

巨人網(wǎng)絡通訊聲明:本文標題《MySQL truncate table語句的使用》,本文關鍵詞  MySQL,truncate,table,語句,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《MySQL truncate table語句的使用》相關的同類信息!
  • 本頁收集關于MySQL truncate table語句的使用的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    三亚市| 固始县| 富阳市| 武定县| 宁远县| 文成县| 鄂托克旗| 五台县| 迭部县| 丰城市| 八宿县| 鱼台县| 历史| 余江县| 仁化县| 中卫市| 大兴区| 稷山县| 宁国市| 平南县| 荣昌县| 博客| 福贡县| 日喀则市| 彭州市| 准格尔旗| 如皋市| 吉安县| 喀喇沁旗| 吉林省| 巴塘县| 米易县| 昌图县| 武定县| 科尔| 应城市| 昌都县| 中西区| 碌曲县| 图木舒克市| 泰宁县|