Here we are going see some useful basic SQL DML commands with syntax and example, which are used frequently while working on SQL. These DML (Data Manipulation Language) Commands are very useful for making changes in table in them. Following are DML commands with syntax and example
List of DML commands:
- Select
- Insert
- Update
- Delete
Select statement is used to fetch data
from table. If you want to fetch all columns you don’t need to write all column
names you can use * instead. It also considered as Data Query language.
Syntax:
Select * from tablename;
Or
Select Column1, column2, column3 from tablename;
Example:
Select ID, First_name, Salary from Employee;
Insert into statement is used to insert
rows in the table.
If we want to insert data in all the
columns then don’t need to specify each column name and its datatype after
insert into statement just by following it’s sequence you can add values. But when
you want to insert only few columns and keep other as it is you need to mention
column name and datatype after insert into statement.
Syntax:
Insert into tablename
(column1 datatype, column2 datatype,
column3 datatype)
Values
(value1, value2, value3);
Insert into tablename
Values
(Value1, value2, value3, value4, value5, value6);
Example:
Insert into Employee
(ID, First_name, Salary)
Values
(111, ‘Nisha’,11000);
Update is use to modify existing record in
the table.
Update tablename
Set column1= value1, column2 = value2
Where condition;
Update Employee
Set Salary = 16000, First_name= ‘Raj’
Delete is use to delete required rows or all
table. Delete can be used with where condition.
There we always read that we can rollback delete
operation but it is only possible when you are using full recovery model or
transaction process. So you can not generally recover all your deleted data as
you think after reading that you can rollback delete operation.
Syntax:
Delete from tablename;
Delete from tablename
Where column1 = value1;
Example:
Delete from Employee;
Delete from Employee
Where ID = 111;
There are Many other commands used in SQL for learning them check next tutorial....
No comments:
Post a Comment
Feel free to ask us any question regarding this post