This statement is used to delete records in a table.
SQL UPDATE Statement
The SQL update statement is used to delete row in a table.
Syntax:
[To update the existing record into the table, we are using SQL UPDATE command as follows:]
DELETE FROM table_name
WHERE column_name=value;
Note:
WHERE clause:
In SQL DELETE Statement, WHERE clause specifies which record should be deleted.
If you don't use WHERE clause,then SQL DELETE condition delete all records.
Data Is Deleted Only in Specified Columns:
The following statement will delete existing record as per the specifies condition in WHERE Clause.
Below is existing "Student" table:
Example 1:
[we delete existing student "Anuj" from "Student" table.]
The following statement are used as to delete a existing "Anuj's " record from the "Student" table:
DELETE FROM Student
WHERE StudentName='Anuj';
Result:
Message Comes: (1 row(s) affected)
NOTE:
DELETE ONE RECORD OF SAME NAME
If there is more then one record of same name then we are using this delete statement as follows:
To delete all rows in a table without deleting the table. The table structure, attributes, and indexes will not be affected we are using this delete statement as follows:
DELETE FROM table_name;
or
DELETE * FROM table_name;
DELETE ONE RECORD OF SAME NAME
If there is more then one record of same name then we are using this delete statement as follows:
DELETE FROM Student
WHERE StudentName='Anuj' and Address='Ghaziabad';
DELETE ALLTo delete all rows in a table without deleting the table. The table structure, attributes, and indexes will not be affected we are using this delete statement as follows:
DELETE FROM table_name;
or
DELETE * FROM table_name;
Conversion Conversion Emoticon Emoticon