鍍金池/ 教程/ 數(shù)據(jù)庫/ SQLite Truncate Table
SQLite Having 子句
SQLite 運算符
SQLite 注入
SQLite Delete 語句
SQLite – Python
SQLite 數(shù)據(jù)類型
SQLite 簡介
SQLite 創(chuàng)建數(shù)據(jù)庫
SQLite Vacuum
SQLite Group By
SQLite 日期 & 時間
SQLite AND/OR 運算符
SQLite 刪除表
SQLite Distinct
SQLite Alter 命令
SQLite PRAGMA
SQLite 約束
SQLite 創(chuàng)建表
SQLite Like 子句
SQLite Limit 子句
SQLite Autoincrement
SQLite 子查詢
SQLite – C/C++
SQLite – PHP
SQLite 命令
SQLite Order By
SQLite Select 語句
SQLite Unions 子句
SQLite – Perl
SQLite – Java
SQLite 別名
SQLite 常用函數(shù)
SQLite Explain(解釋)
SQLite NULL 值
SQLite Glob 子句
SQLite 表達式
SQLite 視圖
SQLite Where 子句
SQLite Truncate Table
SQLite 索引
SQLite Insert 語句
SQLite 安裝
SQLite Indexed By
SQLite 分離數(shù)據(jù)庫
SQLite 觸發(fā)器
SQLite 語法
SQLite Joins
SQLite Update 語句
SQLite 附加數(shù)據(jù)庫
SQLite 事務(wù)

SQLite Truncate Table

在 SQLite 中,并沒有 TRUNCATE TABLE 命令,但可以使用 SQLite 的 DELETE 命令從已有的表中刪除全部的數(shù)據(jù),但建議使用 DROP TABLE 命令刪除整個表,然后再重新創(chuàng)建一遍。

語法

DELETE 命令的基本語法如下:

    sqlite> DELETE FROM table_name;

DROP TABLE 的基本語法如下:

    sqlite> DROP TABLE table_name;

如果您使用 DELETE TABLE 命令刪除所有記錄,建議使用 VACUUM 命令清除未使用的空間。

實例

假設(shè) COMPANY 表有如下記錄:

    ID          NAME        AGE         ADDRESS     SALARY
    ----------  ----------  ----------  ----------  ----------
    1           Paul        32          California  20000.0
    2           Allen       25          Texas       15000.0
    3           Teddy       23          Norway      20000.0
    4           Mark        25          Rich-Mond   65000.0
    5           David       27          Texas       85000.0
    6           Kim         22          South-Hall  45000.0
    7           James       24          Houston     10000.0

下面為刪除上表記錄的實例:

    SQLite> DELETE FROM COMPANY;
    SQLite> VACUUM;

現(xiàn)在,COMPANY 表中的記錄完全被刪除,使用 SELECT 語句將沒有任何輸出。