Data Manipulation Language commands in Oracle
Data Manipulation Language commands in Oracle includes insert, delete and update commands. We will discuss all these Data Manipulation Language commands in Oracle in this section. We will discuss Data Manipulation Language commands in Oracle with some simple examples. Data Manipulation Language is a component of SQL , we can perform various Data Manipulation Language operations on database objects. In Data Manipulation Language component , we can insert records in the tables, we can delete records from database and we can update records of the tables. To insert new records or rows, Insert command can be used. For deletion of records from database tables, Delete command can be used. To update records of table, Update table command can be used.
How to insert records or rows in a table using SQL
Insert command
The insert command is used to insert records or rows in database table. Insert command is very simple in SQL, Insert keyword is used for inserting data in the database tables. Insert command of SQL inserts one record or row at a time.
The general syntax of insert command is as given below:
Insert into table name values( value1,value2,…);
Example
Insert into employee values(‘E001’,’ADAM’, ‘SYDNEY’);
In response to the above insert command , sql will generate the message “1 row(s) created”.
By this way you can insert as many records as you wish.
How to delete rows or records from a table in SQL
How to delete rows or records from a table in SQL
Delete Command
Delete Command is used to delete records from a database table, we can delete any number of records at a time in a single Delete Command. Delete Command of SQL uses Deletekeyword.
The general syntax of Delete Command is as given below
Delete table name [where condition];
Example
Delete employee;
This will delete all the records from employee table.
We can delete particular rows or records of a table.
Delete employee where ename=’Smith’;
This will delete record of Smith only.
We can use multiple conditions in Delete Command.
Suppose we want to delete records of all that employees whose city is Chandigarh and name is Smith.
The SQL delete statement will be like this:
Delete employee where ename=’Smith’ and ecity=’Chandigarh ’;
How to Update records in SQL
Update Command
Update Command is used to update existing records or rows of a database table. Update Command is applied when some changes happens in records. Suppose in case of an employee if he changes his city ,then his record in database must be updated. Another example could be for annual increments in salaries of all the employees, we need update command.
The general syntax of Update Command is give below
Update table name set column name=new value;
Example
Suppose you want to change present city of employee named Adam to Chandigarh
Update employee set ecity=’Chandigarh ’ where ename=’Adam’;
You can also use arithmetic operators in update, like increment the salary of all the employees by 100.
The update statement will be like this:
Update employee set salary=salary+100;
These are the three basic data manipulation operations in SQL.