Professional Documents
Culture Documents
Objectives
2-2
2-3
2-4
Adding a Column
2-5
Modifying a Column
2-6
Dropping a Column
Use the DROP COLUMN clause to drop columns you no
longer need from the table.
ALTER TABLE dept80
DROP COLUMN job_id;
Table altered.
2-7
TABLE <table_name>
UNUSED(<column_name>);
TABLE <table_name>
UNUSED COLUMN <column_name>;
2-8
2-10
Adding a Constraint
Add a FOREIGN KEY constraint to the EMP2 table
indicating that a manager must already exist as a valid
employee in the EMP2 table.
ALTER TABLE emp2
modify employee_id Primary Key;
Table altered.
ALTER TABLE emp2
ADD CONSTRAINT emp_mgr_fk
FOREIGN KEY(manager_id)
REFERENCES emp2(employee_id);
Table altered.
2-11
ON DELETE CASCADE
2-12
Deferring Constraints
Deferring constraint on
creation
2-13
Changing a specific
constraint attribute
Dropping a Constraint
2-14
Disabling Constraints
2-15
Enabling Constraints
2-16
Cascading Constraints
2-18
Cascading Constraints
Example:
ALTER TABLE emp2
DROP COLUMN employee_id CASCADE CONSTRAINTS;
Table altered.
ALTER TABLE test1
DROP (pk, fk, col1) CASCADE CONSTRAINTS;
Table altered.
2-19
Overview of Indexes
Manually
CREATE INDEX statement
CREATE TABLE statement
2-20
2-21
Function-Based Indexes
SELECT *
FROM
dept2
WHERE UPPER(department_name) = 'SALES';
2-23
Removing an Index
2-25
2-26
Syntax:
FLASHBACK TABLE[schema.]table[,
[ schema.]table ]...
TO { TIMESTAMP | SCN } expr
[ { ENABLE | DISABLE } TRIGGERS ];
2-27
2-28
External Tables
2-29
2-31
2-33
2-35
SELECT *
FROM oldemp
OLDEMP
2-37
emp.dat
Summary
2-38
Practice 2: Overview
2-39