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

DBMS Lab Activity

DBMS lab activity
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

DBMS Lab Activity

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

Q.1.

Create Table

The CREATE TABLE command creates a new table in the database.

CODE :

CREATE TABLE Students (

StudentID INT,

FirstName VARCHAR(50),

LastName VARCHAR(50),

Age INT

);

2. Alter Table: Add a Column

The ALTER TABLE command is used to add, delete, or modify columns in an existing table.

Add a new column Email to the Students table:

CODE :

ALTER TABLE Students

ADD Email VARCHAR(100);

3. Alter Table: Modify a Column

Modify the column Age to have a DECIMAL(4, 2) type:

CODE :

ALTER TABLE Students

MODIFY COLUMN Age DECIMAL(4, 2);

4. Alter Table: Drop a Column

Drop a column named EnrollmentDate from the Students table (Note: The column name needs to be
correct, EnrollmentDate instead of EnrollamentDate):

CODE :

ALTER TABLE Students

DROP COLUMN EnrollmentDate;


5. Drop Table

The DROP TABLE command deletes an entire table and all of its data.

CODE :

DROP TABLE Students;

OUTPUT :
Q.2 Run the following SQL Command

CREATE TABLE Employees

EmployeeID INT.

EmployeeName VARCHAR(100),

Date Offeining DATE.

Salary DECIMAL(10, 2),

Bio TEXT

);

The SQL command you've provided has some syntax errors. Here's the corrected SQL command to create
the Employees table:

Corrected CREATE TABLE Command

CODE:

CREATE TABLE Employees (

EmployeeID INT,

EmployeeName VARCHAR(100),

DateOfJoining DATE,

Salary DECIMAL(10, 2),

Bio TEXT

);
Corrections Made:

Replaced . with , to separate columns.

Corrected Date Offeining to DateOfJoining (assuming this was the intended column name).

This command creates a table named Employees with columns for the employee ID, name, date of
joining, salary, and a text bio.

CODE :

OUTPUT :

You might also like