13 March 2014

DELETE Statement in sql



The DELETE statement is used to delete rows from a table.

Syntax

DELETE FROM table_name WHERE column_name = data

Let's Create a table :
create table tbl_student(Id int,Name varchar(200))

Let's Insert Data:
insert into tbl_student values(1,'adi')
insert into tbl_student values(2,'jc')
insert into tbl_student values(3,'balu')
DELETE Statement with where

DELETE FROM tbl_student WHERE Id = 1

Output:
(1 row(s) affected)
DELETE Statement without where
DELETE FROM tbl_student
Output:
(2 row(s) affected)

No comments:

Post a Comment