thrikesh / EX-2-Data-Manipulation-Language-DML-and-Data-Control-Language-DCL-Commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EX 2 Data Manipulation Language (DML) Commands and built in functions in SQL

Date:

AIM:

To create a manager database and execute DML queries using SQL.

DML(Data Manipulation Language)

The SQL commands that deal with the manipulation of data present in the database belong to DML or Data Manipulation Language and this includes most of the SQL statements. It is the component of the SQL statement that controls access to data and to the database. Basically, DCL statements are grouped with DML statements.

List of DML commands:

INSERT: It is used to insert data into a table.
UPDATE: It is used to update existing data within a table.
DELETE: It is used to delete records from a database table.

Create the table as given below:

create table manager(enumber number(6),ename char(15),salary number(5),commission number(4),annualsalary number(7),Hiredate date,designation char(10),deptno number(2),reporting char(10));

insert the following values into the table

insert into manager values(7369,'Dharsan',2500,500,30000,'30-June-81','clerk',10,'John');
insert into manager values(7839,'Subu',3000,400,36000,'1-Jul-82','manager',null,'James');
insert into manager values(7934,'Aadhi',3500,300,42000,'1-May-82','manager',30,NULL);
insert into manager values(7788,'Vikash',4000,0,48000,'12-Aug-82','clerk',50,'Bond');

Q1) Update all the records of manager table by increasing 10% of their salary as bonus.

QUERY:

image

OUTPUT:

image

Q2) Delete the records from manager table where the salary less than 2750.

QUERY:

image

OUTPUT:

image

Q3) Display each name of the employee as “Name” and annual salary as “Annual Salary” (Note: Salary in emp table is the monthly salary)

QUERY:

image

OUTPUT:

image

Q5) List the names of Clerks from emp table.

QUERY:

image

OUTPUT:

271175098-86f71191-94a7-45e6-b756-6020a06350b7

Q6) List the names of employee who are not Managers.

QUERY:

271175146-a65b548c-2cd5-45c9-b21b-89cbdb1114c4

OUTPUT:

271175187-02933c79-0073-4274-9b90-2bc9f4814d8b

Q7) List the names of employees not eligible for commission.

QUERY:

271175220-6d3c980b-752e-4df5-9648-2a4bcf6e1962

OUTPUT:

271175271-f4a825b1-ac41-4d65-9b0c-e59a55e4ca33

Q8) List employees whose name either start or end with ‘s’.

QUERY:

271175311-aec361f2-371a-43c0-8be2-7fae5ecfa2e8

OUTPUT:

271175346-6c098d6f-d039-4325-9810-93275772b07f

Q9) Sort emp table in ascending order by hire-date and list ename, job, deptno and hire-date.

QUERY:

image

OUTPUT:

Q10) List the Details of Employees who have joined before 30 Sept 81.

QUERY:

image

OUTPUT:

image

Q11) List ename, deptno and sal after sorting emp table in ascending order by deptno and then descending order by sal.

QUERY:

image

OUTPUT:

image

Q12) List the names of employees not belonging to dept no 30,40 & 10

QUERY:

image

OUTPUT:

image

Q13) Find number of rows in the table EMP

QUERY:

image

OUTPUT:

image

Q14) Find maximum, minimum and average salary in EMP table.

QUERY:

image

OUTPUT:

image

Q15) List the jobs and number of employees in each job. The result should be in the descending order of the number of employees.

QUERY:

image

Result:

To create a manager database and execute DML queries using SQL is executed successfully.

About