Protected by Copyscape Web Copyright Protection Software

Pages

Search This Blog

Wednesday, December 4, 2013

SQL Lesson 6

Lesson 6:

3) DELETE:

This is used to remove the data from table. We can delete the data based on some conditions also. If we didn’t use where condition it will remove whole data from table.

Syntax: Delete from table_name;

OR

Delete from table_name where condition1;

Ex: Delete from EMP;

It will remove whole data from EMP table.

Select * from EMP;

0 rows selected.

Conditional Delete in SQL:

Select * from EMP;

Delete from EMP where Empno=1;

Select * from EMP;

How to delete Specific column data?

We can’t delete specific column’s data by using Delete command. But there is an option to delete specific column data.

By using update command we can do that.
Select * from EMP;
Update EMP set Comm=null;

So in above example comm data is deleted. We can also delete specific column data of a specific record.

Update EMP Set deptno='' where Empno=4;

Select * from EMP;

Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 7

No comments:

Post a Comment