1.38. SQLite Truncate Table

发布时间 :2025-10-25 12:31:12 UTC      

In SQLite, there is no TRUNCATE TABLE Command, but you can use the SQLite Of DELETE Command to delete all data from an existing table.

1.38.1. Grammar

DELETE The basic syntax of the command is as follows:

sqlite> DELETE FROM table_name;

But this method cannot return the increment to zero.

If you want to return the increment to zero, you can use the following methods:

sqlite> DELETE FROM sqlite_sequence WHERE name = 'table_name';

When SQLite When a self-incrementing column is included in the database, a file named sqlite_sequence Donovan’s watch. This table contains two columns: name and seq . name records the table in which the increment column is located, and seq records the current serial number (the number of the next record is the current serial number plus 1). If you want to zero the sequence number of a self-incrementing column, you only need to modify sqlite_sequence A watch will be fine.

UPDATE sqlite_sequence SET seq = 0 WHERE name = 'table_name';

1.38.2. Example

Hypothetical COMPANY The table has the following records:

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

The following is an example of deleting the record in the above table:

SQLite> DELETE FROM sqlite_sequence WHERE name = 'COMPANY';
SQLite> VACUUM;

Now, the records in the COMPANY table are completely deleted, using the SELECT Statement will have no output.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.