0% found this document useful (0 votes)
3 views

dbms experiment 2,3

The document outlines the creation and manipulation of several SQL tables, including Employee_details, Department_details, salesman, customer, and orders. It includes various SQL commands for inserting data, querying, and deleting records, as well as performing calculations on the data. The document concludes with the creation of a book table and several queries related to book data.

Uploaded by

21urcs030
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)
3 views

dbms experiment 2,3

The document outlines the creation and manipulation of several SQL tables, including Employee_details, Department_details, salesman, customer, and orders. It includes various SQL commands for inserting data, querying, and deleting records, as well as performing calculations on the data. The document concludes with the creation of a book table and several queries related to book data.

Uploaded by

21urcs030
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

CREATE TABLE Employee_details(

empno INT PRIMARY KEY,

name VARCHAR(30),

Dateofbirth DATE,

address VARCHAR(30),

dateofjoining DATE,

mobileno INT,

deptno INT REFERENCES Department_details(deptno),

salary INT

);

CREATE TABLE Department_details (

deptno INT PRIMARY KEY,

deptname VARCHAR(30),

location VARCHAR(30)

);

INSERT INTO Department_details VALUES(30,'IT','vilampatti');

INSERT INTO Department_details VALUES(31,'CSE','Sivakasi');

INSERT INTO Department_details VALUES(32,'ECE','Virudhunagar');

INSERT INTO Department_details VALUES(33,'CSE','Amathur');

INSERT INTO Department_details VALUES(101,'Civil','Theni');

INSERT INTO Department_details VALUES(35,'IT','Thirunelveli');

select *from Department_details;

INSERT INTO Employee_details VALUES(1,'Harini','30-03-2004','vilampatti','03-03-


2020',9791205961,30,23000);

INSERT INTO Employee_details VALUES(2,'Muthu','29-02-2004','Sivakasi','04-04-


2020',9787134358,31,25000);

INSERT INTO Employee_details VALUES(3,'Vishnu','28-03-2004','Virudhunagar','05-05-


2021',8489490100,32,50000);

INSERT INTO Employee_details VALUES(4,'Priya','27-03-2004','Amathur','06-06-


2022',979350988,33,10000);
INSERT INTO Employee_details VALUES(5,'Hari','26-03-2004','Thirunelveli','07-07-
2022',9787134350,35,10000);

select *from Employee_details;

SELECT deptno from Department_details minus SELECT deptno from Employee_details;

SELECT Department_details.location,Employee_details.name from


Department_details,Employee_details where
Department_details.deptno=Employee_details.deptno;

delete from Department_details where deptno=101;

select *from Department_details;

drop table Employee_details;

drop table Department_details;

CREATE TABLE salesman(

id INT PRIMARY KEY,

name VARCHAR(30),

city VARCHAR(30),

commission float

);

CREATE TABLE customer(

cusid INT PRIMARY KEY,

cusname VARCHAR(30),

city VARCHAR(30),

grade INT,

id INT REFERENCES salesman(id)

);

CREATE TABLE orders(

ordno INT,

purchamt INT,

orddate DATE,
cusid INT REFERENCES customer(cusid),

id INT REFERENCES salesman(id)

);

INSERT INTO salesman VALUES(1,'Backiya','Italy',0.12);

INSERT INTO salesman VALUES(2,'Muthu','Rome',0.24);

INSERT INTO salesman VALUES(3,'Bala','Paris',0.13);

INSERT INTO salesman VALUES(4,'Harini','Rome',0.15);

INSERT INTO salesman VALUES(5,'Priya','Italy',0.23);

INSERT INTO customer VALUES(30,'Harini','Rome',1,1);

INSERT INTO customer VALUES(31,'Bakiya','Italy',2,2);

INSERT INTO customer VALUES(32,'Bhuvi','Rome',3,3);

INSERT INTO customer VALUES(33,'Mala','paris',4,4);

INSERT INTO customer VALUES(34,'Muthu','Paris',5,5);

INSERT INTO orders VALUES(1322,23000,'30-03-2020',30,1);

INSERT INTO orders VALUES(2322,25000,'31-03-2022',31,2);

INSERT INTO orders VALUES(2532,30000,'28-02-2022',32,3);

INSERT INTO orders VALUES(2422,29000,'11-02-2021',33,4);

INSERT INTO orders VALUES(4569,40000,'12-02-2022',34,5);

select *from salesman;

select *from customer;

select *from orders;

SELECT * FROM Salesman WHERE city IN ('Paris', 'Rome')

SELECT id, name, city, commission FROM Salesman WHERE city NOT IN ('Paris', 'Rome');

select *from salesman where commission between 0.12 and 0.14;

select *from customer where cusname like 'B%';

select salesman.name,customer.cusname ,salesman.city from salesman,customer where


salesman.city=customer.city;
select *from orders order by ordno ASC;

drop table orders;

drop table customer;

drop table salesman;

create table book(

book_name varchar(30),

author_name varchar(30),

price int,

quantity int

);

INSERT INTO book values('DBNS','Haripriya',459,23);

INSERT INTO book values('Os','Harini',439,23);

INSERT INTO book values('AI','Anu',450,30);

INSERT INTO book values('EVS','Abinaya',300,49);

INSERT INTO book values('DBMS','Muthu',490,50);

select *from book;

select min(quantity) from book;

select sum(price*quantity) as totalprice from book;

select avg(price) as averageprice from book;

select max(quantity)from book;

select count(*) from book;

select book_name from book where price>400;

select author_name from book where author_name like 'A%';

--------------------------------------------------------------------------------------------------------------------------------------

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy