MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL Truncate Table Statement

The MySQL TRUNCATE TABLE statement is used to remove all records from database table. The truncate table statement is similar to delete statement without a WHERE clause. MySQL truncate table statement is more powerful compare to delete statement.

Note: Be careful when truncating database table, it remove all the records in the database table!

MySQL TRUNCATE TABLE Syntax

To remove all records from existing table, use the following syntax:

Syntax

TRUNCATE TABLE tablename;

Parameters:

tablename: The table name from which you want to remove all records.

MySQL TRUNCATE TABLE Data example

The following MySQL statement to remove all records from "tblCustomer" table:

Example

TRUNCATE TABLE tblCustomer;

Note:

In the above example, we have deleted the record for customer "Sunil Shetty".

You can use MySQL Command Line Client to remove all records from "tblCustomer" table. It will look like this:

Show TRUNCATE Data Example

You can check the records has removed from table by the following query:

Example

SELECT * FROM tblCustomer; 

You can use MySQL Command Line Client to check the deleted data in table. It will look like this: