



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




SQL>create table Students(stud_id number primary key,student_name varchar(50) not null,DOB date,door_no int,street varchar(50),city varchar(50) ,pin int); Table created. SQL>create table Class1(class_id int primary key,class_name varchar(50),student_id REFERENCES Students(stud_id),DOJ date,hours int); Table created. SQL>create table Subjects(sub_id int primary key,sub_name varchar(50),teacher varchar(50),student_id int REFERENCES Students(stud_id)); Table created. SQL>create table section(section_id int primary key,class_id int REFERENCES Class1(class_id),section_name varchar(50)); Table created.
SQL>alter table student2 add constraint b1 check(city in('Banglore','Chennai','Hyderabad','Mumbai','Delhi')); Table altered.
SQL> alter table clas add constraint b2 check(hours>10); Table altered.
SQL> insert into student values(&Student_ID,'&Student_name',&DOB,&door_no,'&street','&city',&pin); Enter value for stud_id: 1 Enter value for student_name: A Enter value for dob: DATE '2001-12-23' Enter value for door_no: 1111 Enter value for street: vaidharayam Enter value for city: chennai Enter value for pin: 60017 old 1: insert into student values(&Student_ID,'&Student_name',&DOB,&door_no,'&street','&city',&pin) new 1: insert into student values(1,'A',DATE '2001-12-23',1111,'nellai','salem',12345) 1 row created. SQL> insert into class values(&class_id,'&class_name',&Student_ID,&doj,&hours); SQL> insert into subject values(&subject_id,'&subject_name','&teacher',&Student_ID);
SQL>alter table students add totalmarks int; Table altered
update table students set totalmarks=140 where studid=1; update table students set totalmarks=165where studid=2; update table students set totalmarks=180 where studid=3; update table students set totalmarks=200 where studid=4;
SQL>Select totalmarks from students where totalmarks in(select max(totalmarks) from students where totalmarks not in(select max(totalmarks) from students)); 9.SQL>select count(stud_id) from students group by (DOB); COUNT(STUD_ID)