0% found this document useful (0 votes)
64 views6 pages

Assignment No 5

The document describes creating tables, constraints, views, indices and sequences for a database to store student and hostel information. It includes creating tables for students, hostels, hostel assignments, contact details, mess, employees. It also demonstrates altering tables, truncating tables, dropping tables, creating views and indices. Sample DML queries like select, insert, update, delete are also shown.

Uploaded by

ranjeet
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)
64 views6 pages

Assignment No 5

The document describes creating tables, constraints, views, indices and sequences for a database to store student and hostel information. It includes creating tables for students, hostels, hostel assignments, contact details, mess, employees. It also demonstrates altering tables, truncating tables, dropping tables, creating views and indices. Sample DML queries like select, insert, update, delete are also shown.

Uploaded by

ranjeet
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/ 6

ASSIGNMENT NO 5

TITLE : Create tables with appropriate constraints for the relational schema. Create views,
indices, and sequence. Alter the schema by adding / removing columns and constraints. Write
DML queries.

Name: Ranjeet R Raigawali Roll no : 75 Batch:4th

Grno:182012 Branch: IT

CREATE TABLE :

create table student

stud_id number(10),

f_name varchar2(100),

m_name varchar2(100),

l_name varchar(100),

primary key(stud_id)

);

create table hostel

h_id number(10),

h_name varchar(100),

h_type varchar(50),

no_of_seats number(10),

primary key(h_id)

);

create table hostel_stud

(
room_no varchar(30),

stud_id number(10),

h_id number(10)

);

ALTER TABLE :

alter table hostel_stud add foreign key (h_id) references hostel(h_id);

alter table hostel_stud add foreign key (stud_id) references student(stud_id);

create table stud_mobile

stud_id number (10),

s_mobno number (10) primary key

);

alter table stud_mobile add foreign key(stud_id) references student(stud_id);

desc stud_mobile;

create table parent_no

stud_id number(10),

parent_no number(10),

foreign key(stud_id) references student(stud_id)

);

create table mail_id

mail_id varchar(100) primary key,

stud_id number(10),
foreign key (stud_id) references student(stud_id)

);

desc mail_id

create table mess1

mess_id number(10) primary key,

h_id number(10),

workers varchar(100),

foreign key (h_id) references hostel(h_id)

);

create table mess2

mess_name varchar(100),

menu varchar(500),

mess_id number (10),

foreign key (mess_id) references mess1(mess_id)

);

create table stud_mess

stud_id number(10),

mess_id number(10),

foreign key (stud_id) references student(stud_id),

foreign key (mess_id) references mess1(mess_id)

);
create table visitor

v_id number (30) primary key,

h_id number(10),

reasonforcoming varchar(500),

intime varchar(100),

outtime varchar(100),

foreign key (h_id) references hostel(h_id)

);

create table employee1

emp_id number(30) primary key,

h_id number(10),

emp_name varchar(200),

foreign key (h_id) references hostel(h_id)

);

create table employeee2

emp_id number(30),

area_of_working varchar2(200),

intime varchar2(500),

outtime varchar2(500),

foreign key (emp_id) references employee1(emp_id)

);
TRUNCATE TABLE :

truncate table student;

DROP TABLE :

drop table mess1;

CREATE VIEW :

create view student_view as

select f_name, m_name

from student

where stud_id=1;

CREATE INDEX :

create index hostel_index

on hostel(h_name,no_of_seats);

CREATE SEQUENCE :

create sequence stud_seq

start with 1

increment by 1

minvalue 1

maxvalue 1000;

DML (DATA MANIPULATION LANGUAGE) :

SELECT :

select * from student

select * from student where stud_id = 1;


select * from hostel where h_name = gagangiri;

INSERT :

insert into student values (stud_seq.nextval,'Ranjeet','Raman','Raigawali');

insert into hostel values (h_id = 2,’Sahaygiri’,’boys’,’500’);

UPDATE :

update hostel

set h_name = 'sahayagiri',h_type = 'girls'

where h_id = 1;

DELETE :

delete from HOSTEL where H_id=5;

delete from student where stud_id =42;

You might also like