You are on page 1of 3

1|Page

Muhammad Samhan Bin Azamain (01-060156). BIT 13/02 Database System C1.
QUESTIONS 1. Write the SQL code that will create a database Departmental_Info. 2. Create a departments table that stores department id, department name and location information. The Primary Key for the departments table should be the department id. Departments Department_Id Int PK Department_Name Varchar(50) Not null Location Varchar(25) 3. Having created the table structure in Question 2, write the SQL code that will enter the rows into the tables Department_Id Department_Name Location 1 Information Technology B1 2 Marketing B1 3 Registry B4 4 Accounts B2 4. 5. 6. 7. 8. 9. 10. Write SQL Statement to count number of records in department table. Write SQL Statement to check how many departments located under location B1. Write SQL Statement to display department name in ascending and descending order. Write SQL Statement to check which department located under B2. Write SQL Statement to search department name have character e. Drop table Department. Drop database Departmental_Info.

ANSWERS(Codings). 1. create database Departmental_Info; 2. create table Departments ( Department_Id int, PRIMARY KEY(Department_Id), Department_Name varchar(50) not null, Location varchar(25) ); 3. insert into Departments(Department_Id, Department_Name, Location) values(1,Information Technology,B1),

2|Page (2,Marketing,B1), (3,Registry,B4), (4,Accounts,B2); select count(*) from Departments; select count(*) from Departments where Location=B1; Ascending order: select * from Departments order by Department_Name asc; Descending order: select * from Departments order by Department_Name desc; select * from Departments where Location=B2; select * from Departments where Department_Name like %e%; drop table Departments; drop database Departmental_Info;

4. 5. 6.

7. 8. 9. 10.

ANSWERS(Output)

3|Page

You might also like