DML (Data Manipulation Language) Commands.

DML Commands:

  • DML is abbreviation of Data Manipulation Language.
  • It is used to  insert, update and delete data in a database.
  • INSERT –  Inserts data into a table
  • UPDATE – Updates existing data into a table
  • DELETE – Deletes all records from a table

Insert Command

The SQL Server Insert into statement is used to add new rows of data to a table in the database.

Syntax

Following are the two basic syntaxes of INSERT INTO statement.

INSERT INTO TABLE_NAME [(column1, column2, column3,…columnN)]  VALUES (value1, value2, value3,…valueN)

Insert  into  <table-name>  values(val1,val2,val3,——–valn)

Example’s:

Insert into student (sno,name) values (10,’mahesh’)

Insert into student values(1,’sambireddy’,’male’,26)

Delete Command:

  • This command is used to delete the records from the table based on some condition.

Syntax:    delete from <table-name> where [condition]

Example:  delete  from  student  where  age = 26

  • Delete all the records in a table we can use delete from <table-name>

Update Command:

  • This command is used to modify or update the existing records in a table.

Syntax:  update  <table-name> set col-1=val-1, col-2=val-2, ——— col-n=val-n where [condition]

Example:   update   student  set  name=’srpv’  where  sno=1

Select Command:

  • This command is used to retrieve the information from the table.
  • SQL ServerSELECT statement is used to fetch the data from a database table which returns data in the form of result table. These result tables are called result-sets.

Syntax:    select col-1,col-2,col-3, – – – – – – ,col-n from <table-name>

Example:    select sno, name from student

  • If you select all columns we can put * instead of all column names.

Select * from <table-name>

Eg: select   * from  student

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s