0% found this document useful (0 votes)
49 views4 pages

SQL Queries-Employee Database Aim:: Ex No

1. The document describes creating tables for an employee database with tables for employee, department, contact, and salary information. 2. It includes the CREATE statements to build each table with the relevant columns, as well as INSERT statements to populate the tables with sample data. 3. The document also includes several SELECT statements to query and retrieve data from the tables.

Uploaded by

SNEKHA R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views4 pages

SQL Queries-Employee Database Aim:: Ex No

1. The document describes creating tables for an employee database with tables for employee, department, contact, and salary information. 2. It includes the CREATE statements to build each table with the relevant columns, as well as INSERT statements to populate the tables with sample data. 3. The document also includes several SELECT statements to query and retrieve data from the tables.

Uploaded by

SNEKHA R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

EX NO: 04

DATE : 22-02-2021

SQL Queries-Employee Database

AIM:

To create a table with the following schema:

1. employee(eno , ename, dept, salary, deptno)


2. dept(deptno, dept, Mname, rollno)
3. contact(eno, doorno, city, pincode, mobno, email)
4. salary(eno,bascic_salary,HRA,DA,Total)

PROCEDURE:

1. employee

CREATE TABLE employee (eno INT,ename VARCHAR(20),dept VARCHAR(5),salary


INT);

ALTER TABLE employee ADD deptno INT;

INSERT INTO employee VALUES(12354,'SNEGA','IT',10000,01);

INSERT INTO employee VALUES(34214,'MAADHINI','IT',9000,01);

INSERT INTO employee VALUES(16754,'TEJA','CSE',6000,02);

INSERT INTO employee VALUES(12678,'POOJA','CSE',7500,01);

INSERT INTO employee VALUES(12356,'VARUN','IT',8500,01);

select dept,salary FROM employee WHERE ename like 'V%';

select * FROM employee ORDER by eno;


2. dept

CREATE TABLE dept(deptno INT,dept VARCHAR(5),Mname VARCHAR(20));

ALTER TABLE dept ADD rollno INT;

INSERT INTO dept VALUES(01,'IT','SNEKHA',08);

INSERT INTO dept VALUES(01,'IT','VAISHU',11);

INSERT INTO dept VALUES(02,'CSE','DEEPIKA',05);

INSERT INTO dept VALUES(01,'IT','MONI',17);

INSERT INTO dept VALUES(02,'MECH','NAYEEMA',23);

select Mname FROM dept WHERE dept='IT' or dept='MECH';

select deptno FROM dept WHERE Mname='VAISHU';

select * FROM dept order by Mname;


3. contact

CREATE TABLE contact (eno INT,doorno VARCHAR(5),city VARCHAR(20),pincode


INT,mobno INT,email VARCHAR(50));

INSERT INTO contact


VALUES(21548,'12A','Chennai',600061,9451256801,'[email protected]');

INSERT INTO contact


VALUES(25236,'11C','Trichy',600045,6386325401,'[email protected]');

INSERT INTO contact


VALUES(26541,'3G','Chennai',600021,9154260327,'[email protected]');

INSERT INTO contact


VALUES(29562,'12C','Chennai',600028,7513269840,'[email protected]');

INSERT INTO contact


VALUES(32015,'9A','Coimbatore',600011,9475162035,'[email protected]');

UPDATE contact set city='Madurai' WHERE doorno='3G';

select * from contact WHERE doorno='3G' and eno=26541;

selectdoorno,mobno FROM contact WHERE city like '%e';

select * FROM contact;


4. salary

CREATE TABLE salary (eno INT,basic_salary INT,HRA INT,DA INT);

ALTER TABLE salary add Total NUMBER;

INSERT INTO salary VALUES(41520,50000,10000,5000,65000);

INSERT INTO salary VALUES(45203,10000,5000,4000,19000);

INSERT INTO salary VALUES(15230,20000,6000,3000,23000);

INSERT INTO salary VALUES(20153,10000,1000,2000,13000);

INSERT INTO salary VALUES(12530,40000,4000,400,48000);

UPDATE salary SET Total='29000' WHERE eno='15230';

select Total from salary WHERE eno=20153 and DA=2000;

select * FROM salary order by Total;

select * FROM salary;

You might also like