0% found this document useful (0 votes)
5 views3 pages

tp3.sql

The document outlines the SQL commands for creating three tables: DEPT, EMP, and SALGRADE, including their respective constraints and relationships. It also includes various data manipulation commands to insert records into these tables. Additionally, it demonstrates modifications to the EMP table, such as adding and dropping columns and constraints.

Uploaded by

Yahya Habachi
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)
5 views3 pages

tp3.sql

The document outlines the SQL commands for creating three tables: DEPT, EMP, and SALGRADE, including their respective constraints and relationships. It also includes various data manipulation commands to insert records into these tables. Additionally, it demonstrates modifications to the EMP table, such as adding and dropping columns and constraints.

Uploaded by

Yahya Habachi
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/ 3

Tp3 28/10/2023

Part1

create table DEPT

(deptno number(2),

dname char(15) check ((dname = UPPER(dname)) and (dname in ('ACCOUNTING' , 'RESEARCH' ,


'SALES' , 'OPERATIONS'))),

loc varchar(4000) unique,

constraint pk_deptno primary key (deptno)

create table EMP

(empno number(4) ,

ename char(15),

job char(15) not null,

sal number(4,2) not null,

hiredate date not null,

comm number(4,2),

deptno number(2),

constraint pk_empno primary key (empno),

constraint const_deptno foreign key (deptno) references DEPT (deptno)

create table SALGRADE

grade number(2) primary key,

lowsal number(4),

highsal number(4)

alter table EMP add ( MGR number(4))


alter table EMP add constraint const_mgr foreign key (mgr) references EMP (empno)

alter table EMP add constraint const_sal check (sal>=600)

alter table EMP drop constraint const_sal

alter table EMP rename column comm to commission

alter table EMP add lname char(4)

alter table EMP modify column lname varchar(50) ;

alter table EMP drop column lname

create synonym employee for EMP

drop synonym employee

part2

insert into DEPT values(10,'ACCOUNTING','new york')

insert into DEPT values(20,'RESEARCH','DALLAS')

insert into DEPT values(30,'SALES','chicago')

insert into DEPT values(40,'OPERATIONS','boston')

insert into SALGRADE values(1,700,1200)

insert into SALGRADE values(2,1201,1400)

insert into SALGRADE values(3,1401,2000)

insert into SALGRADE values(4,2001,3000)

insert into SALGRADE values(5,3001,9999)

insert into EMP(empno,ename,job,mgr,hiredate,sal,commission,deptno)


values(7839,'king','president',null, date '2008-06-02',5,null,30)

insert into EMP(empno,ename,job,mgr,hiredate,sal,commission,deptno)


values(7521,'ward','salesman',7839, date '2001-02-21',10,50,30)
insert into EMP(empno,ename,job,mgr,hiredate,sal,commission,deptno)
values(7654,'martin','salesman',7839, date '2011-11-06',10,50,30)

insert into EMP(empno,ename,job,mgr,hiredate,sal,commission,deptno)


values(7698,'blake','manager',7839, date '2009-04-01',10,null,30)

insert into EMP(empno,ename,job,mgr,hiredate,sal,commission,deptno)


values(7566,'jones','manager',7698, date '2008-09-01',22,null,20)

insert into EMP(empno,ename,job,mgr,hiredate,sal,commission,deptno)


values(7788,'scott','analyst',7698, date '2008-12-17',33,null,10)

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