Oracle

Adding a Constraint Syntax

Figo Kim 2007. 1. 9. 23:04
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
ALTER TABLE  <table_name>
ADD [CONSTRAINT  <constraint_name.]
type (<column_name>);
  • Enable or Disable a constraint
  • Can't modify
  • Add "NOT NULL" by using "MODIFY" clause

    Only if the table is empty or every row of the table is filled.
ALTER TABLE emp2
modify employee_id Primary Key;

ALTER TABLE emp2
ADD CONSTRAINT emp_mgr_fk
FOREIGN KEY(manager_id) REFERENCES emp2(employee_id)


ALTER TABLE emp2 ADD CONSTRAINT emp_dt_fk
FOREIGN KEY (Department_id)
REFERENCES departments ON DELETE CASCADE;
** When data in the parent key is deleted, all rows in the child table that depend on the delete parent key values are also deleted.

'Oracle' 카테고리의 다른 글

Function-Based Indexes  (0) 2007.01.10
Adding a Constraint Syntax  (0) 2007.01.09
The guideline of Modifying a Column  (0) 2007.01.09
The guideline of Modifying a Column  (0) 2007.01.09
Revoking Object Privileges  (0) 2007.01.09