DB Lab Session 2
DB Lab Session 2
LAB SESSION - 2
2 CONTENTS
Introduction
DBMS
DB DATA-TYPES
o Create Database
o Create Tables
TABLE: COURSE
RECID COURSECODE COURSETITLE CREDITHR.
1 SENG2031 DB 3
4
DBMS … (1)
allowing users to create, read, update, and delete data in the database.
DBMS manage the data, the database engine, and the database
other programs.
DATATYPE DESCRIPTION
DDL (Data Definition Language) : DDL commands define and manage the structure of a database.
These commands affect the schema and are mostly related to creating, modifying, or deleting
database objects.
TRUNCATE – Removes all records from a table but keeps its structure.
9
DDL and DML … (2)
DML (Data Manipulation Language)DML commands are used to manipulate and manage data
Syntax: INSERT INTO Table_name (column_1, column_2, …. column_n) VALUES (value_1, value_2, … value_n);
INSERT INTO Instructor (RecID, InstName, Dept, Rank) VALUES (1, “Ujulu”, “SENG”, “Lecturer”);
INSERT INTO Student (RecID, StudName, Dept, Batch) VALUES (1, “Obang”, “SENG”, “2015”);
INSERT INTO Course (RecID,CourseCode, CourseTitle, CreditHr.) VALUES (1, “SENG2031”, “DB”, 3);
13
PRACTICAL EXAMPLES … (4)
Syntax: ALTER TABLE Table_name ADD COLUMN Column_Name Datatye AFTER Column_name; // Add Column
Example: ALTER TABLE instructor ADD COLUMN Phone INT AFTER RANK;
Syntax: ALTER TABLE Table_name DROP COLUMN Column_Name; // Removing existing Column