0% found this document useful (0 votes)
14 views2 pages

Sample Table For View

Uploaded by

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

Sample Table For View

Uploaded by

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

create table department

(dno int primary key,


dname varchar(20) not null unique,
dloc varchar(20));

insert into department values (10,'HR','Pune');


insert into department values (20,'Sales','Mumbai');
insert into department values (30,'Research','Banglore');
insert into department values (40,'Admin','Chennai');
insert into department values (50,'Production','Ahemdabad');

create table employee


(eno int primary key,
ename varchar(20) not null,
city varchar(15),
gender char,
age int,
phone int,
salary float,
mno int,
dno int,
constraint employee_fk_mno foreign key (mno) references employee (eno) on delete
set null,
constraint employee_fk_dno foreign key (dno) references department (dno) on delete
set null);

insert into employee values


(101,'Jeevika','Mumbai','F',19,9876543210,41000,null,10);
insert into employee values (102,'Kirti','Mumbai','F',19,8765432109,41000,null,20);
insert into employee values (103,'Hemant','Pune','M',20,7654321098,42000,null,30);
insert into employee values
(104,'Jatin','Kolkatta','M',21,6543210987,43000,null,40);
insert into employee values
(105,'Harshita','Delhi','F',18,5432109876,42000,101,10);
insert into employee values
(106,'Kritika','Banglore','F',19,4321098765,43000,102,20);
insert into employee values
(107,'Sahil','Ahemdabad','M',20,3210987654,41000,104,40);
insert into employee values (108,'Muskan','Pune','F',21,9876543211,44000,101,10);
insert into employee values
(109,'Priyanka','Delhi','F',20,8765432112,43000,102,20);
insert into employee values (110,'Pooja','Mumbai','F',21,8765432113,44000,104,40);
insert into employee values (111,'Daksh','Mumbai','M',19,9876554433,41000,101,10);
insert into employee values
(112,'Dhruwal','Kolkatta','M',20,8765443322,42000,102,20);
insert into employee values
(113,'Aastha','Ahemdabad','F',20,7654322111,43000,103,30);
insert into employee values (114,'Kush','Chennai','M',23,6543211444,41000,104,40);
insert into employee values
(115,'Hiral','Banglore','F',22,9876665544,42000,103,30);
insert into employee values (116,'Mohit','Delhi','M',22,8765656565,43000,102,20);
insert into employee values (117,'Jiya','Delhi','F',19,6565654545,41000,104,40);
insert into employee values (118,'Jovita','Mumbai','F',19,9876543222,41000,101,10);
insert into employee values (119,'Vansh','Mumbai','M',19,8765430909,41000,102,20);
insert into employee values (120,'Devesh','Pune','M',21,7654321218,42000,103,30);
insert into employee values
(121,'Gaurav','Kolkatta','M',22,6543210909,43000,104,40);
insert into employee values (122,'Hardik','Delhi','M',20,5432109898,42000,101,10);
insert into employee values
(123,'Harshit','Banglore','M',21,4321098787,43000,102,20);
insert into employee values
(124,'Hirday','Ahemdabad','M',22,3210987676,41000,104,40);
insert into employee values (125,'Tisha','Pune','F',21,9876543232,44000,101,10);
insert into employee values (126,'Krishna','Delhi','M',20,8765432222,43000,102,20);
insert into employee values (127,'Diksha','Mumbai','F',21,8765433333,44000,104,40);
insert into employee values
(128,'Karan','Mumbai','M',21,8765444333,44000,null,null);

create table test(eno int primary key,


name varchar(20) not null,
city varchar(20) not null,
phone int, constraint test_phone_un unique(phone),
email varchar(30), constraint test_email_un unique(email),
gender char, constraint test_gender_chk check (gender = 'M' or gender = 'F'),
age int, constraint test_age_chk check (age >= 18),
salary float default 40000,
mno int, constraint test_mno_fk foreign key(mno) references test(eno));

You might also like