1. Use SQL commands to perform following operations: a. Display a list of available databases b. Create the database (choose any appropriate name in the format c. Select your database d. Create a table: i. Create a relation with the name DEPARTMENT ii. It has four attributes namely Dept_id, Dept_name, Building, and Budget iii. Dept_id is an integer, Dept_name is a character string of maximum length 20, Building is a character string of maximum length 15, and Budget is a number with 12 digits in total, 2 of which are after the decimal point iv. The create table command should also specify Dept_name attribute as not null and set a default value for Building to ‘A’ e. Drop the table DEPARTMENT f. Add attribute Phone to DEPARTMENT relation using Alter command g. Drop attribute Budget from a relation DEPARTMENT by using Alter command h. Modify datatype of Dept_id to varchar(25) using Alter command 2. Put all your output screenshots along with SQL commands in a single PDF file and upload in Moodle
DROP TABLE DEPARTMENT;
--create table
CREATE TABLE DEPARTMENT (
Dept_id int not null,
Dept_name varchar(20) not null,
Building varchar(15) DEFAULT 'A',
Budget decimal(10,2)
);
Comments
Leave a comment