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.