Deletes all rows from a table without deleting the table.
TRUNCATE TABLE table-name
The TRUNCATE TABLE statement deletes all rows from a table and the MobiLink server is not informed of their removal upon subsequent synchronization. It is equivalent to executing the following statements:
STOP SYNCHRONIZATION DELETE; DELETE FROM TABLE; START SYNCHRONIZATION DELETE;
After a TRUNCATE TABLE statement, the table structure, all the indexes, and the constraints and column definitions continue to exist; only data is deleted.
TRUNCATE TABLE cannot execute if a statement that affects the table is already being referenced by another request or query. Similarly, UltraLite does not process requests referencing the table while that table is being altered. Furthermore, you cannot execute TRUNCATE TABLE when the database includes active queries or uncommitted transactions.
For UltraLite.NET users: You cannot execute this statement unless you also call the ULBulkCopy.Dispose method for all data objects (for example, ULDataReader).
Statements are not released if schema changes are initiated at the same time.
If the table contains a column defined as DEFAULT AUTOINCREMENT or DEFAULT GLOBAL AUTOINCREMENT, TRUNCATE TABLE resets the next available value for the column.
Once rows are marked as deleted with TRUNCATE TABLE, they are no longer accessible to the user who performed this action, unless the user issues a ROLLBACK statement. However, they do remain accessible from other connections. Use COMMIT to make the deletion permanent, thereby making the data inaccessible from all connections.
If you synchronize the truncated table, all INSERT statements applied to the table take precedence over a TRUNCATE TABLE statement.
The following statement deletes all rows from the Departments table.
TRUNCATE TABLE Departments
If you execute this example, be sure to execute a ROLLBACK statement to revert your change.