sqlite

Database; use; embedded relational database

truncate

英[trʌŋˈkeɪt] US[ˈtrʌŋkeɪt ]

vt. Shorten

table

English [ˈteɪbl] US [ˈtebəl]

n. Table; table, directory ; operating table, workbench, game table; flat floor

vt. tabulation; shelving; fitting; shelving

adj.table

SQLite Truncate Table instruction syntax

Function:In SQLite, there is no TRUNCATE TABLE command, but you can use SQLite's DELETE command to delete all data from an existing table, but it is recommended to use the DROP TABLE command to delete the entire table, and then Create it again.

Syntax: The basic syntax of the DELETE command is as follows:

sqlite> DELETE FROM table_name;

##The basic syntax of DROP TABLE is as follows:

sqlite> DROP TABLE table_name;

SQLite Truncate Table instruction example

假设 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;
现在,COMPANY 表中的记录完全被删除,使用 SELECT 语句将没有任何输出。