2. ALTER TABLE Statement
⢠The ALTER TABLE statement is used to add, delete,
or modify columns in an existing table.
⢠The ALTER TABLE statement is also used to add
and drop various constraints on an existing table.
3. âşTo add a column in a table, use the
following syntax:
âş ALTER TABLE table_name
ADD column_name datatype;
ALTERTABLE Statement
4. âşTo delete a column in a table, use
the following syntax :
âşALTER TABLE table_name
DROP COLUMN column_name;
ALTERTABLE Statement
5. ALTER TABLE Statement
âşTo change the data type of a
column in a table, use the following
syntax:
âşALTER TABLE table_name
MODIFY column_name datatype;
7. TRUNCATE COMMAND
âşThe Truncate SQL command is used to delete all
records from an existing oracle table.
âşRemoving rows with the TRUNCATE TABLE statement
can be faster than removing all rows with the
DELETE statement, especially if the table has
numerous triggers, indexes, and other
dependencies.
8. âşTruncate drops the table first and then recreates
only the table structure which is much faster than
deleting the records one by one.
âş Hence in case a table contains large number of
records, it works much faster than delete
statement.
TRUNCATE COMMAND
10. DROP COMMAND
âş The DROP command is used to remove an object from
the database.
âş If u drop a table, all the rows in the table is deleted
and the table structure is removed from the database.
âş Once a table is dropped we cannot get it back, so be
careful while using drop command.
âş When a table is dropped all the references to the
table will not be valid.
11. âş Syntax :
DROP TABLE TABLE_NAME;
âş Example:
DROP TABLE EMP;
DROP TABLE DEPARTMENT;
DROP COMMAND
12. Difference
TRUNCATE DROP
Truncate command removes all
records from the specified table, but
keeps structure of the table intact.
Drop command removes all records
from the table along with the table
structure and puts it in recycle bin.
The records once deleted with
truncate command cannot be
recovered with the help of rollback.
The table removed with the drop
command can be recovered from the
recycle bin with the help of flashback
command.
13. Difference
TRUNCATE DELETE
Truncate command removes all
records from the specified table.
Delete command can delete one
or more records from the table.
The records once deleted with
truncate command cannot be
recovered with the help of
rollback.
The records once deleted with
delete command can be
recovered with the help of
rollback.