0% found this document useful (0 votes)
1 views

4) SQL Commands

The document outlines the four main DDL commands used in database management: create, alter, drop, and truncate. It provides syntax and examples for each command, detailing their specific functions such as creating database objects, modifying structures, permanently deleting objects, and removing data while retaining table structure. The document emphasizes the differences between drop and truncate operations, particularly regarding subsequent alterations to the table.

Uploaded by

aman mishra
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)
1 views

4) SQL Commands

The document outlines the four main DDL commands used in database management: create, alter, drop, and truncate. It provides syntax and examples for each command, detailing their specific functions such as creating database objects, modifying structures, permanently deleting objects, and removing data while retaining table structure. The document emphasizes the differences between drop and truncate operations, particularly regarding subsequent alterations to the table.

Uploaded by

aman mishra
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

Day-01

27-02-2025
===============

DDL Commands:
===========
-> Four DDL commands:
1) create
2) alter
3) drop
4) truncate

create:
-------
-> when we want to create any database object like table,
we can use "create" command
-> when we want to create the new user also we can use
"create" command"
-> when we want to create new database also we can use
"create" command.
Syntax:
create database-object object-name(
);

Ex: for creation of the table:


===================
create table EcommerceTable(
Sno int,
ProductId int,
ProductName char(40),
ProductDescription varchar(300),
ProductCost int
);

alter:
------
-> to change anything on the defined structure of the
database object, we can use "alter" command.
Like:
1) table name
2) column name
3) add new element
4) we can change the type of the column.

Syntax:
alter database-object object-name;

Ex: alter table EcommerceTable add total int;


alter table EcommerceTable modify ProductId smallint;
drop:
-----
-> to delete any database object which we have created
permanently, we can use "drop".
Ex:
drop table EcommerceTable;

-> after the drop operation, we cannot perform any alter


operation on the dropped table.

truncate:
----------
-> truncate is same as drop,
truncate can delete the values of the table but it can
maintain the table structure as empty.
Ex:
truncate table EcommerceTable;

-> after the truncate operation, we can able to perform use


"alter" on the table object.

You might also like