Database Reference
In-Depth Information
Deleting or dropping a table will delete almost everything that is connected to it. All of the
data in that table will be gone. The table structure, indexes, constraints, and privileges will
be lost
Syntax:
DROP TABLE tablename;
Example: Delete table Student and all the data in it.
Sol:
DROP TABLE Student; Renaming Tables
In Oracle RDBMS, RENAME statement is used to change the name of a table. The basic
syntax for all rename operations requires that specify the old name and a new name.
Syntax:
RENAME oldtablename To newtablenam;
Example: Change the name of Student table to Stuent_info. Sol:
RENAME Student To Student_info;
Creating a Table from an Existing Table
The most common way to create a table is with the CREATE TABLE command. However,
some time it is required to create a table similar to the existing table and fill it with similar
data for temporary modification. Oracle RDBMS provides an alternative method of creat-
ing tables, using the same format and data of an existing table.
Syntax:
CREATE TABLE NEW_TABLE(field1, field2, field3) AS
(SELECT field1, field2, field3 FROM OLD_TABLE <WHERE...>
This syntax allows us to create a new table with the same data types as those of the fields
that are selected from the old table. The fields in the new table can be renamed by giving
them new names.
Example:
CREATE TABLE Staff_CSE(StaffID, Name, Designation) AS
(SELECT StaffID, Name, Designation FROM Staff WHERE Department ='CSE'); This
command select rows with StaffID, Name, Designation fields from table
Staff of CSE department and stores selected data into newly created table Staff_CSE.
Search WWH ::




Custom Search