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

Database Exercise 1

The document creates and populates multiple tables in a database. It creates tables for employees (SEMP), departments (SDEPT), suppliers (S), products (P), jobs (J), and a join table for suppliers, products and jobs (SPJ). It inserts records into these tables and runs queries to select, update, and delete records.

Uploaded by

AKSHAY PATIL
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Database Exercise 1

The document creates and populates multiple tables in a database. It creates tables for employees (SEMP), departments (SDEPT), suppliers (S), products (P), jobs (J), and a join table for suppliers, products and jobs (SPJ). It inserts records into these tables and runs queries to select, update, and delete records.

Uploaded by

AKSHAY PATIL
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

show databases;

use cdacmumbaipgdacsep2021;
create table SEMP(EMPNO CHAR(4),EMPNAME CHAR(20), BASIC FLOAT, DEPTNO
CHAR(2),DEPTHEAD CHAR(4));
show tables;
select * from SEMP;
create table SDEPT(DEPTNO CHAR(2), DEPTNAME CHAR(15));
insert into SDEPT values('10','Development');
insert into SDEPT values('20','Training');
select * from SDEPT;
insert into SEMP values ('0001','SUNIL',6000,'10','');
insert into SEMP values ('0002','HIREN',8000,'20','');
insert into SEMP values ('0003','ALI',4000,'10','0001');
insert into SEMP values ('0004','GEORGE',6000,'','0002');
delete from SEMP where EMPNO='0004';
create table S (SNO char(4), SNAME char(20),STATUS INT, CITY char(10));
create table P (PNO CHAR(4), PNAME CHAR(20), COLOR CHAR(10), WEIGHT FLOAT,CITY
CHAR(10));
create table J (JNO CHAR(4),JNAME CHAR(20),CITY CHAR(10));
create table SPJ(SNO CHAR(4),PNO CHAR(4),JNO CHAR(4),QTY INT);
show tables;
insert into S values
('S1','SONY',10,'LONDON'),
('S2','PETER ENGLAND',20,'LONDON'),
('S3','LENOVO',30,'PARIS'),
('S4','DELL',40,'ATHENS');
DROP TABLE S;
SELECT * FROM S WHERE CITY='LONDON';
SELECT * FROM S WHERE CITY='PARIS' OR CITY='ATHENS';
insert into P values
('P1','NIKON','WHITE',2,'LONDON'),
('P2','CANON','BLACK',3,'PARIS'),
('P3','SHANON','GOLD',4,'ATHENS');
update P set WEIGHT=12 where PNO='P1';
update P set WEIGHT=13 where PNO='P2';
update P set WEIGHT=15 where PNO='P3';
select * from P;
SELECT * FROM P WHERE CITY='LONDON';
insert into J values
('J1','JAVA','LONDON'),
('J2','ORACLE','PARIS'),
('J3','SELENIUM','ATHENS');
SELECT * FROM J;
SELECT * FROM J WHERE CITY='ATHENS';
SELECT PNAME FROM P WHERE WEIGHT=12 OR WEIGHT=15;
SELECT SNAME FROM S WHERE STATUS>=20;
SELECT PNAME FROM P WHERE WEIGHT BETWEEN 12 AND 14;
SELECT SNAME FROM S WHERE CITY NOT IN ('LONDON');
SELECT WEIGHT,WEIGHT*1000 AS 'MILIGRAMS',WEIGHT/1000 AS 'KILOGRAM' FROM P;
SELECT CITY FROM S;

You might also like