Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » UltraLite - Database Management and Reference » UltraLite SQL Statement Reference

UltraLite STOP SYNCHRONIZATION DELETE statement Next Page

UltraLite TRUNCATE TABLE statement


Deletes all rows from a table, without deleting the table definition.

Syntax

TRUNCATE TABLE table-name

Remarks

The TRUNCATE TABLE statement deletes all rows from a table and the MobiLink server is not informed of their removal upon subsequent synchronizations. It is equivalent to executing the following statements:

STOP SYNCHRONIZATION DELETE;
DELETE FROM TABLE;
START SYNCHRONIZATION DELETE;
Note

This statement should be used with great care on a database involved in synchronization or replication. Because the MobiLink server is not notified, this deletion can lead to inconsistencies that can cause synchronization or replication to fail.

After a TRUNCATE TABLE statement, the table structure and all of the indexes continue to exist until you issue a DROP TABLE statement. The column definitions and constraints remain intact.

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 Dispose method for all data objects (for example, ULDataReader). See Dispose method.

Schema changes    Statements are not released if schema changes are initiated at the same time. See Schema changes with DDL statements.

Side effects

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. However, they do remain accessible from other connections. Use ROLLBACK to make them re-accessible to the current user. Use COMMIT to physically delete the rows, and thereby make the data unaccessible from all connections.

If you synchronize the truncated table, all INSERT statements applied to the table take precedence over a TRUNCATE TABLE statement.

See also
Example

Delete all rows from the Departments table.

TRUNCATE TABLE Departments