Professional Documents
Culture Documents
SYSTEMS
OBJECTIVES
Creating a Table from a Table using CREATE statement.
Inserting Data into a Table from another Table using
INSERT statement.
Delete Operations
Renaming Table
Truncating Table
Destroying Table
2
CREATING A TABLE FROM A TABLE
USING CREATE STATEMENT.
Syntax: CREATE TABLE <TableName>(<ColumnName 1>, …,
<ColumnName N>) AS SELECT <ColumnName 1>, …,
<ColumnName N> FROM <TableName>
Example:
insert into empstruct select
empno,ename,job,hiredate,sal from emp where
dpetno = 10 or job = ’Assistant Professor’;
6
DELETE OPERATIONS
Removal of All Rows:.
Syntax: DELETE FROM <TableName>;
Example: Empty the emp table.
DELETE FROM empstruct;
Example:
ALTER TABLE emp ADD(spouse
varchar2(40));
10
MODIFYING THE STRUCTURE OF TABLE
12
TRUNCATING TABLE
Syntax: TRUNCATE TABLE <TableName>;
Example: TRUNCATE TABLE da;
TRUNCATE TABLE empties a table completely. Logically,
this is equivalent to a DELETE statement that deletes all rows,
but there are practical differences under some circumstances.
TRUNCATE TABLE differs from DELETE in the
following ways:
Truncate operations drop and re-create table, which is
much faster than deleting rows one by one.
Truncate operations are not transaction-safe (i.e. an error
will occur if an active transaction or an active table lock
exists).
The numbers of deleted rows are not returned.
13
DESTROYING TABLE
Syntax: DROP TABLE <TableName>;
Example: DROP TABLE da;
14
Thank You