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

DBMS Practice

Uploaded by

Sawsan Abu Farha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

DBMS Practice

Uploaded by

Sawsan Abu Farha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DBMS Practice Sheet in Week 5

1. Define New Schema using your userID_P1 (e.g., ABC0221234_P1)


Command: Create Database ABC0221234_P1;

2. Make your database as the default database


Command: Use ABC0221234_P1;

3. Create the following tables:

create table department

( Dept_ID varchar(5),
Dept_name varchar(20),
Dept_Building varchar(20),
Dept_budget numeric(8,2),
primary key(Dept_ID) );

create table course

( course_id varchar(8),
course_title varchar(50) not null,
dept_ID varchar(5),
course_credits numeric(2,0),
primary key (course_id));

create table Instructor

( Inst_ID varchar(6),
Inst_Name varchar(20),
Inst_salary numeric(8,2),
Dept_ID varchar(5),
course_ID varchar(8),
primary key(Inst_ID));

4. Add default Value to dept_budget in the department table.

5. Change the character type of the Dept_Building in Department table to become Varchar(30).
6. Insert Data into Tables

insert into department values ('1', 'Math', 'Science', 100434.54);


insert into department values ('2', 'Biology', 'Science', 110434.54);
insert into department values ('3', 'Geology', 'Science', 120434.54);

insert into course values ('238', 'The Music of Donovan', '7', 3);
insert into course values ('608', 'Electron Microscopy', '7', 3);
insert into course values ('539', 'International Finance', '6', 3);

insert into instructor values ('101', 'Tomas',10234.20, '1', '581');


insert into instructor values ('102', 'John',12234.25, '8', '338');
insert into instructor values ('103', 'Samer',14224.24, '3', '241');

7. Delete from Instructor Table the Instructors whose names begin with ‘T’;
Delete from Instructor
where Inst_Name ….. ;

8. Add 0.05 to instructors’ salaries with salaries >=1000$;


Update Instructor
set Inst_Salary = Inst_Salary * 1.05
where Inst_Salary ……;

9. Write SQL query to get all instructors whose names consist of three characters.

You might also like