In this tutorial we will demonstrate the use of delete statement. The DELETE statement is used to delete records in a table.
General delete syntax
Sql;DELETE FROM table_name WHERE some_column=some value;
--first lets drop the table Test (if she exists, if not skip the drop line).Drop table test;
create table test (id int,name varchar(20),email varchar(20));
insert into test values (1,'Eve','[email protected]');
insert into test values (2,'Jon','[email protected]');
insert into test values (3,'Mike','[email protected]');
insert into test values (4,'Paul','[email protected]');
SQLselect * from test;
ID NAME EMAIL
---------- -------------------- --------------------
1 Eve [email protected]
2 Jon [email protected]
3 Mike [email protected]
4 Paul [email protected]
SQLdelete from test where id=1;
SQL
select * from test ;
ID NAME EMAIL
---------- -------------------- --------------------
2 Jon [email protected]
3 Mike [email protected]
4 Paul [email protected]
Sql DELETE FROM table_name;
Sql delete from test;
Sql select * from test;
Sql DELETE * FROM table_name;