You are on page 1of 3

Aim:

Implement Data Manipulation Language commands - Insert, Select, Update, and Delete.

1. INSERT:
Purpose:
To add records to the table
Syntax:
a.Direct method-
only one record can be inserted in the field at a time
• Insert into<table name>values<values for all columns>;
Example queries:
insert into employee values(3,'Brindha',123,9100,'CSE');
OUTPUT:
1 row inserted.

b.Null method-
we can skip some field
• Insert into<table name>(column name)values(values for columns);
Example queries:
insert into employee(eno,sal) values(11,5000);
OUTPUT:
1 row inserted.

c.Macro method-
More than one value can be inserted in the field at a time.
• Insert into<table name>values<&column names>;
Example queries:
Command to insert records into employee table.
SQL >.insert into employee values ( &eno, ’&ename’ ,&dno ,&sal, ‘&dname’); Enter value for eno:1
Enter value for ename:D.Abinaya
Enter the value for dno:111
Enter the value sal:8000
Enter the value for dname:IT
Old 1:insert into employee values(&eno,’&ename’,&dno,&sal,’&dname’ New 1:insert into employee
values(1,’D.Abinaya’,111,8000,’IT’)
Output:
1 row created
To execute the command which is in buffer
SQL>/
Enter value for eno:2
Enter value for ename: P.Ratha
Enter value for dno:111
Enter value for sal:8900
Enter value for dname:IT
Old 1: insert into employee values (&eno,’&ename’,&dno,&sal,’&dname’); New 1: insert into
employee values (2,’P.Ratha’,111,8900,’IT’)
Output:
1 row created
2. SELECT:
Purpose: Syntax:
To retrieve or view records with in the table
Syntax:
• Select * from<table name>
Example queries:
select * from employee;
Output:
ENO ENAME DNO SAL DNAME
---------------------------------------------
1 Abinaya 111 8000 IT
2 P.Ratha 111 8900 IT
3 Brindha 123 9100 CSE
4 Ajay 123 9110 CSE
5 Indira 145 7500 AI
6 Adhi 145 7900 AI
8 Harsha 132 9900 EIE
9 Mithuna 133 8900 EIE
10 Sahana 133 9990 EIE
11 5000

10 rows selected.
• Select *from <table name> where(condition)
Example queries:
Display enmae,dno from employee where sal>9000.
SQL>Select ename,dno from employee where sal>9000;
Output:
ENAME DNO
-----------------
Brindha 123
Ajay 123
Harsha 132
Sahana 133
4 rows selected.
• Select (column name) from<table name>
Example queries:
Find out the names of all the employees
SQL>select ename from employee;
Output:
ENAME
---------------
D.Abinaya
P.Ratha
Brindha
Ajay
Indira
Adhi
Harsha
Mithuna
Sahana
10 rows selected
3. UPDATE:
Purpose:
To modify records with in the table
Syntax:
• Update<table name>set(column name)=(value)where(condition)
Example queries:
SQL> update employee set ename='Raju' where eno=11;
OUTPUT:
1 row updated.

• Update<table name>set(column name)=(value);


Example queries:
updating all values of the column
SQL> update employee set sal=9000;
OUTPUT:
11 rows updated.

4. DELETE:
Purpose:
To modify records from a table.
Syntax:
• Delete from<table name>where(condition)
Example queries:
Delete a specific record from the table.
SQL> delete from employee where ename='Ajay';
OUTPUT:
1 row deleted.

• Delete from<table name>


Example queries:
Delete all rows in a table without deleting the table
SQL> delete from employee;
OUTPUT:
10 rows deleted.

Result:
Thus, DML Queries were executed.

You might also like