Update, Delete, DROP commands in SQL
Update
UPDATE is the SQL verb that changes or modifies data values in a table. The syntax for update is
UPDATE <TABLE NAME> SET < COLUMN NAME = new value> [where <condition>]
For example if we want to change class of any student in our STUDENT TABLE we want to change class for roll no 10001 from BCA to B TECH. For this type following statement
UPDATE STUDENT SET CLASS = B TECH WHERE ROLL_NO IS 10001;
Delete
By the help of Update command you can update data values in fields. Now what if you want to delete some rows or a single row from a table, you can do this with the help of DELETE command.
DELETE command removes table rows when it meets some specified conditions and not the individual field values.
Syntax for removing a specific row from any table is as :
DELETE FROM<;TABLE NAME> WHERE <condition>
Now for example if we want to delete roll no 10001 from STUDENTS table we use following statement:
DELETE FROM STUDENTS WHERE ROLL_NO = 10001;
To remove all the contents of a table you would enter the following command
DELETE FROM <TABLE NAME>;
This command would made the table empty.
DROP command
Drop command is used to remove TABLE or VIEW definition from a database.
Syntax for Drop command is:
For removing Table
DROP TABLE <TABLE NAME>;
For removing View
DROP VIEW <VIEW NAME>;