約束簡介
?
?
1、?
約束有以下幾種類型
Not Null
Unique
Primary Key
Foreign Key
Check
以上幾個約束,與
SQL Server
的標(biāo)準(zhǔn)一致
,
不再解釋。
?
2、?
添加約束
舉例:
Alter table employees
Add constraint emp_manager_fk
? Foreign key(manager_id) references employees(employee_id);
|
?
3、?
刪除約束
Alter table employees
Drop constraint emp_manager_fk;
|
?
4、?
使約束無效
舉例:
Alter table employees
Disable constraint emp_emp_id_pk casecade;
|
?
5、?
使約束有效
舉例:
Alter table employees
Enable constraint emp_emp_id_pk;
|
?
6、?
查看約束
舉例
1
:查看表的所有約束:
Select constraint_name,constraint_type,search_condition
From user_constraints
Where table_name=’EMPLOYEES’;
|
??????
?????????????
舉例
2
:查看約束關(guān)聯(lián)的列
select constraint_name,column_name
from user_cons_columns
where table_name='TFLOW'
|
?
?