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

SQL Code

The document creates a database and two tables, inserts data into the tables, and defines constraints on the tables.

Uploaded by

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

SQL Code

The document creates a database and two tables, inserts data into the tables, and defines constraints on the tables.

Uploaded by

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

create database TATA;

use TATA;
create table dept
(deptno integer not null primary key,
dname varchar(10) not null,
Loc varchar(15) not null);

create table emp


(empno integer not null primary key,
ename varchar(10) not null,
address char(20) not null,
sal decimal(10,2) check(sal>=5000),
comm integer,
deptno integer references dept(deptno) on delete cascade on update cascade);

insert into dept


values(1100,'finance','Delhi');
insert into dept
values(1101,'security','Lucknow');
insert into dept
values(1102,'management','Mumbai');

insert into emp


values(12002,'Aman','Lucknow',45000,1500,1101);
insert into emp
values(12003,'Shivansh','Lucknow',55000,2000,1101);
insert into emp
values(12004,'Sumit','Delhi',35000,1500,1100);
insert into emp
values(12005,'Samaira','Mumbai',65000,2500,1102);
insert into emp
values(12006,'Maithli','Mumbai',50000,2000,1102);

You might also like