0% found this document useful (0 votes)
13 views4 pages

CSE 208 Lab 1 52 - 6

The document outlines the basic SQL commands for creating and managing databases and tables, including CREATE, SELECT, INSERT, ALTER, and DROP statements. It provides specific structures and examples for each command, as well as a list of tasks for a database systems lab. The tasks involve creating databases and tables, inserting data, modifying table structures, and displaying data in various formats.

Uploaded by

Arifur Rahman
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)
13 views4 pages

CSE 208 Lab 1 52 - 6

The document outlines the basic SQL commands for creating and managing databases and tables, including CREATE, SELECT, INSERT, ALTER, and DROP statements. It provides specific structures and examples for each command, as well as a list of tasks for a database systems lab. The tasks involve creating databases and tables, inserting data, modifying table structures, and displaying data in various formats.

Uploaded by

Arifur Rahman
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/ 4

Bangladesh University of Business and Technology

Department of Computer Science and Engineering


CSE 208: Database Systems Lab
Lab 01 Tasks - Introduction

Commands
The CREATE DATABASE statement
Structure:
1 CREATE DATABASE database_name ;
Example:
1 CREATE DATABASE bubt_cse208 ;

The CREATE TABLE statement


Structure:
1 CREATE TABLE table_name
2 (
3 column_1 data_type ,
4 column_2 data_type ,
5 .
6 .
7 );
Example:
1 CREATE TABLE student
2 (
3 ID INT ,
4 NAME VARCHAR (30) ,
5 SEMESTER VARCHAR (5)
6 );
You can explore some more data types here.

The SELECT statement


Structure 1:
1 SELECT * FROM table_name ;
Example:
1 SELECT * FROM student ;
Structure 2:
1 SELECT col1 , col2 FROM table_name ;
Example:
1 SELECT NAME , SEMESTER FROM student ;

Spring 25, Lab 1 1 Tasmia Binte Sogir


The INSERT INTO statement
Structure 1:
1 INSERT INTO table_name
2 VALUES ( value1 , value2 , ...) ;
Example:
1 INSERT INTO student
2 VALUES (41201 , ' Tasmia ' , '2 nd ') ;
Structure 2:
1 INSERT INTO table_name ( col1 , col2 , ...)
2 VALUES ( value1 , value2 , ...) ;
Example:
1 INSERT INTO student ( NAME )
2 VALUES ( ' Saad ') ;

The ALTER TABLE - ADD Column statement


Structure:
1 ALTER TABLE table_name
2 ADD column_name data_type ;
Example:
1 ALTER TABLE student
2 ADD intake VARCHAR (5) ;

The ALTER TABLE - ALTER/MODIFY Column statement


Structure:
1 ALTER TABLE table_name
2 ALTER COLUMN column_name data_type ;
Example:
1 ALTER TABLE student
2 ALTER COLUMN intake INT ;

Note: For some versions of MySQL, you would need to use MODIFY instead.
Structure:
1 ALTER TABLE table_name
2 MODIFY COLUMN column_name data_type ;
Example:
1 ALTER TABLE student
2 MODIFY COLUMN intake INT ;

Spring 25, Lab 1 2 Tasmia Binte Sogir


The ALTER TABLE - CHANGE Column statement
Structure:
1 ALTER TABLE table_name
2 CHANGE old_column_name new_column_name datatype ;
Example:
1 ALTER TABLE student
2 CHANGE s_name student_name VARCHAR (40) ;

The ALTER TABLE - RENAME COLUMN statement


For some MySQL versions, you can use the ”RENAME COLUMN” statement.
Note: You must write ”COLUMN” after ”RENAME” to avoid changing the name of the whole table.
Structure:
1 ALTER TABLE table_name
2 RENAME COLUMN old_column_name TO new_column_name ;
Example:
1 ALTER TABLE student
2 RENAME COLUMN student_name TO s_name ;

The ALTER TABLE - DROP Column statement


Structure:
1 ALTER TABLE table_name
2 DROP column_name ;
Example:
1 ALTER TABLE student
2 DROP intake ;

The DROP TABLE statement


Structure:
1 DROP TABLE table_name ;
Example:
1 DROP TABLE student ;

Spring 25, Lab 1 3 Tasmia Binte Sogir


Tasks
1. Create a database named cse208 sec6

2. Create a table named employee with columns - id, name, salary, hometown

3. Enter 5 values into the employee table

4. Display the entire employee table

5. Only display the name of the employees

6. Only display the ID and salary of the employees

7. Create a table named department with columns - dept name, building, room, budget

8. Add a new column “FacultyCount” with datatype VARCHAR to the department table

9. Change the datatype of “FacultyCount” to INT

10. Insert some values for “FacultyCount” in the department table

11. Enter 5 values into the department table

12. Display the entire department table

13. Only display the dept name, building, budget of the departments

14. Change “budget” to “budget 2025” in the department table

15. Remove the room column from the department table

Spring 25, Lab 1 4 Tasmia Binte Sogir

You might also like