0% found this document useful (0 votes)
9 views3 pages

DBMS Lab-2 (0901CD231057)

Uploaded by

rohankalme4
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)
9 views3 pages

DBMS Lab-2 (0901CD231057)

Uploaded by

rohankalme4
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/ 3

Practical: 02 August 21, 2024

Problem Statement- 1:

Implementation of DDL commands of SQL with suitable examples

1. Create table
Solution:
_____________________________________________________________________

CREATE :
This command is used to create a new table in SQL. The user has to give information like
table name, column names, and their datatypes.

Syntax –

CREATE TABLE table_name


(
column_1 datatype,
column_2 datatype,
column_3 datatype,
....
);
Example –
We need to create a table for storing Student information of a particular College. Create
syntax would be as below.

CREATE TABLE Student_info


(
College_Id number(2),
College_name varchar(30),
Branch varchar(10)
);

_____________________________________
Name: Rohan Kalme Enroll:0901CD231057 Batch: B2
Practical: 02 August 21, 2024

Problem Statement- 2:

2.Alter table

Solution:
_____________________________________________________________________

ALTER :
This command is used to add, delete or change columns in the existing table. The user needs
to know the existing table name and can do add, delete or modify tasks easily.

Syntax –
Syntax to add a column to an existing table.

ALTER TABLE table_name


ADD column_name datatype;
Example –
In our Student_info table, we want to add a new column for CGPA. The syntax would be as
below as follows.

ALTER TABLE Student_info


ADD CGPA number;

Name: Rohan Kalme Enroll:0901CD231057 Batch: B2


Practical: 02 August 21, 2024

Problem Statement- 3:

3.Truncate

Solution:

_____________________________________

TRUNCATE :
This command is used to remove all rows from the table, but the structure of the table still
exists.

Syntax –
Syntax to remove an existing table.

TRUNCATE TABLE table_name;


Example –
The College Authority wants to remove the details of all students for new batches but wants
to keep the table structure. The command they can use is as follows.

TRUNCATE TABLE Student_info;

_____________________________________

Name: Rohan Kalme Enroll:0901CD231057 Batch: B2

You might also like