02 134222 107 119459103194 05052024 034404pm 3
02 134222 107 119459103194 05052024 034404pm 3
TASK 2:
Create a replica of Std table with all the students that belong to BSCS program
select *
into clone_std
from std
where ProgID = (select ProgID from prog where ProgName like 'BSCS' );
select * from clone_std;
NAME: TALHA HAIDER.
CLASS: BSCS 4-B.
ENROLLMENT: 02-134222-107.
TASK 3:
Add a column ‘Address’ in replicated Teacher Table.
TASK 4:
Drop column ‘Address’ from replicated table.
TASK 5:
Add columns ‘House No’ character ,’Street No’ numeric, ’Area’ character ,’City’ character in
replicated Teacher Table with the respective data types.
TASK 6:
Change the data type of ‘House No’ from character to numeric.
TASK 7:
Create the Data Definitions for each of the relations shown below, using SQL DDL.
Assume the following attributes and data types: …………………….
create table Faculty(
FacultyID int,
FacultyName varchar(25),
primary key (FacultyID)
);
create table Ccourse(
CourseID varchar(8),
CourseName varchar(25),
primary key (CourseID)
);
create table Class(
ClassID int,
CourseID varchar(8),
SectionNo int,
Semester varchar(10),
primary key (ClassID),
Foreign key (CourseID) references Ccourse(CourseID),
);
TASK 8:
Add an attribute, Class and Phone to the STUDENT table.
alter table student
add class varchar(50),Phone varchar(11)
select * from Student
TASK 9:
Change StudentName size from 25 characters to 20 characters
TASK 10:
Remove all records from student table.
TASK 11:
Remove newly created Faculty and Course tables
NAME: TALHA HAIDER.
CLASS: BSCS 4-B.
ENROLLMENT: 02-134222-107.
TASK 12:
Create a table DEPARTMENT with the following attributes:
DEPTNO int, DNAME varchar(10), LOC varchar(10).
Apply PRIMARY KEY constraint on DEPTNO.
TASK 13:
Create a table EMPLOYEE with the following attributes:
EMPNO int, ENAME varchar(10),SAL int, DEPTNO int.
Apply FOREIGN KEY constraint on DEPTNO referencing the DEPARTMENT table
created in question 1 and PRIMARY KEY constraint on EMPNO.
TASK 14:
ALTER table EMPLOYEE created in question 2 and apply the constraint CHECK on ENAME
attribute such that ENAME should always be inserted in capital letters.
TASK 15:
ALTER table DEPARTMENT created in question 1 and apply constraint on DNAME such that
DNAME should not be entered empty.
TASK 16:
ALTER table EMPLOYEE created in question 2 and apply the constraint on SAL attribute such
that no two salaries of the employees should be similar.
TASK 17:
ALTER table DEPARTMENT created in question 1 and apply the constraint on DNAME such
that no 2 Department are of the same name