Monday, June 18, 2012

Saturday, June 9, 2012

SQL: Data Manipulation Language Commands

In this post, we are going to see the DML commands of SQL.


  • Insert
  • Delete
  • Update
Insert:
This is used to insert data into the table. In the previous section we learnt how to create a table. Let's insert some data into the table now. The syntax for insertion is:
insert into table_name values(...)

 To see the data inserted, we can select the data from the table.

Note that the data entered must adhere to the datatype, else it would throw exception.

Delete:
Used to delete data from the table.

delete from employee where column=some_value.


In case we do not specify any condition, all the rows would be deleted.

Update:

Say, I want to update one of the values of the table. I want to change the name of the employee having employee id as 1 to Ravi. It can be done using the update command. 


We would see more examples on all these commands in the coming posts.