Monday, July 28, 2008

RENAME, DELETE and TRUNCATE

Renaming a Table

Name of a table can be chaged by using Rename command. Rename command has the following syntax.

Syntax: Rename Oldname to Newname;
Example: The following example changes the name of student table to stu.
Rename Student to Stu;


Deleting a Table


A table can be deleted by using Drop Table command. Drop Table command has the following syntax.

Syntax: Drop Table Tablename;
Example: The following example deletes marks table.
Drop Table Marks;


TRUNCATE

In oracle, the truncate command lets you remove all the rows in the table and reclaim the space for other uses without removing the table definition from the database.

Syntax: Truncate Table Tablename;

Example: The following example deletes all rows in marks table, keeping marks table definition within the database.

Truncate Table Marks;

No comments: