You are on page 1of 2

Exp: DB01

*********
Q 01)
-----
create table tbl_student (name char(15), USN varchar(10), branch varchar(10), ge
nder char(1));
create table tbl_employee (emp_name varchar(20), emp_id varchar(6), dept varchar
(15), gender char(1), DoB date, address varchar(25), marital_status varchar(9));
create table tbl_busdtls (
reg_no varchar(10) not null primary key,
mdl_name varchar(15) not null,
type varchar(10) not null,
capacity number(2) check (capacity > 0) );
alter table tbl_busdtls add constraint chk_type check (type in ( Ordinary , SemiLuxur
y , Delux ));
create table tbl_placedtls (
place_code varchar(6) not null primary key,
place_name varchar(15) not null);
create table tbl_tktdtls (
ticket_no number(6) not null,
bus_no varchar(10) not null,
seat_no number(2) not null,
dt_of_jrny date not null,
psgnr_name char(15) not null,
gender char(1) not null,
age number(3),
frm_stn varchar(15),
to_stn varchar(15),
arrvl_time varchar(8) not null,
dprtr_time varchar(8) not null,
constraint pk_tktdtls primary key (ticket_no, bus_no, seat_no, dt_of_jrny));
alter table tbl_tktdtls add foreign key (bus_no) references tbl_busdtls(reg_no);
alter table tbl_tktdtls add foreign key (frm_stn) references tbl_placedtls(place
_code);
alter table tbl_tktdtls add foreign key (to_stn) references tbl_placedtls(place_
code);

Q 02)
-----
alter table tbl_student modify branch varchar(20);
alter table tbl_student add (DoB date, address varchar(40));
alter table tbl_student add primary key (USN);
alter table tbl_student add constraint chk_USNlen check (length(USN) = 10);
alter table tbl_student add constraint chk_gender check (gender in ( M , F ));
alter table tbl_employee rename to tbl_emp;
alter table tbl_emp drop column marital_status;
Q 03)
-----
drop table tbl_emp;
================================================================================
===================================
spool d:\dbms\<USN>_exp01.txt
select table_name, owner from all_tables where owner = '<USER_ID>';
select constraint_name, constraint_type, table_name, owner from all_constraints
where owner='<USER_ID>'
spool off

You might also like