Skip to content

TRUNCATE TABLE

TRUNCATE TABLE removes all rows from a table.

See also CREATE TABLE.

Syntax

sql
TRUNCATE TABLE [IF EXISTS] tab_name

Parameters

tab_name: The name of the table to truncate.

Examples

sql
create table  mkw_doku.my_table1 (ord string, col1 integer);
insert into   mkw_doku.my_table1 (select 'a' as ord, 10 as col1
                                  union all 
                                  select 'b' as ord, 20 as col1
                                  union all
                                  select 'c' as ord, 30 as col1);
select count(*) from  mkw_doku.my_table1;   
+----------+
| count(*) |
+----------+
| 3        |
+----------+
sql
truncate table mkw_doku.my_table1;           
 
select count(*) from  mkw_doku.my_table1;
+----------+
| count(*) |
+----------+
| 0        |
+----------+