MYSQL TRUNCATE statement removes the complete data without removing its structure.
The TRUNCATE TABLE statement is used when you want to delete the complete data from a table without removing the table structure.
Syntax:
TRUNCATE TABLE table_name;
Example:
This example specifies how to truncate a table. In this example, we truncate the table "cus_tbl".
TRUNCATE TABLE cus_tbl;
See the table:
SELECT* FROM cus_tbl;
MySQL DROP Table
MYSQL DROP table statement removes the complete data with structure.
Syntax:
DROP TABLE table_name;
Example:
This example specifies how to drop a table. In this example, we are dropping the table "cus_tbl".
DROP TABLE cus_tbl;
MySQL TRUNCATE Table vs DROP Table:-
You can also use DROP TABLE command to delete complete table but it will remove complete table data and structure both. You need to re-create the table again if you have to store some data. But in the case of TRUNCATE TABLE, it removes only table data not structure. You don't need to re-create the table again because the table structure already exists.
Subscribe channel on YouTube
Read this post on Blogger
Like page on Facebook
Tweet about video on twitter
Let's chat on whatsapp
See you at Instagram
The TRUNCATE TABLE statement is used when you want to delete the complete data from a table without removing the table structure.
Syntax:
TRUNCATE TABLE table_name;
Example:
This example specifies how to truncate a table. In this example, we truncate the table "cus_tbl".
TRUNCATE TABLE cus_tbl;
See the table:
SELECT* FROM cus_tbl;
MySQL DROP Table
MYSQL DROP table statement removes the complete data with structure.
Syntax:
DROP TABLE table_name;
Example:
This example specifies how to drop a table. In this example, we are dropping the table "cus_tbl".
DROP TABLE cus_tbl;
MySQL TRUNCATE Table vs DROP Table:-
You can also use DROP TABLE command to delete complete table but it will remove complete table data and structure both. You need to re-create the table again if you have to store some data. But in the case of TRUNCATE TABLE, it removes only table data not structure. You don't need to re-create the table again because the table structure already exists.
Subscribe channel on YouTube
Read this post on Blogger
Like page on Facebook
Tweet about video on twitter
Let's chat on whatsapp
See you at Instagram

Comments
Post a Comment