成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Oracle數據庫約束

數據庫 Oracle
Oracle數據庫是甲骨文公司的一款關系數據庫管理系統。到目前仍在數據庫市場上占有主要份額。下文中主要為大家講解Oracle數據庫的約束。

Oracle數據庫是大家平時的工作中經常會用到的,本文將為大家帶來Oracle數據庫約束的講解,希望對大家能夠有所幫助。

最近一張表上有兩列字段,要求這兩列要么都有值,要么都為空,簡單的table定義沒辦法實現這種要求,需要利用Oracle的constraint(約束)機制。約束主要是用來保證數據的完整性。

可以從TOAD的設置上,很容易看到約束分為4種,分別是主鍵(Primary Key),檢查(Check),唯一性(Unique),外鍵(Foreign Key)。另外還有兩種是NOT NULL和REF,REF就是其中的一列或者幾列是另外一張表中的值。

下面是對著6中的詳細介紹。

NOT NULL constraint prohibits a database value from being null.

Unique constraint prohibits multiple rows from having the same value in the same column or combination of columns but allows some values to be null.

Primary Key constraint combines a NOT NULL constraint and a unique constraint in a single declaration. It prohibits multiple rows from having the same value in the same column or combination of columns and prohibits values from being null.

Foreign Key constraint requires values in one table to match values in another table.

Check constraint requires a value in the database to comply with a specified condition.

REF column by definition references an object in another object type or in a relational table. A REF constraint lets you further describe the relationship between the REF column and the object it references.

toad create constraint step 1

對于我們的要求,符合的是Check,可以通過增加一個條件是( A is null and B is null ) or ( A is not null and B is not null) 的約束來實現。

對于約束,主要的狀態有兩種,一個是Status on Creation,也就是在表中增加數據或修改數據時是否使用約束,可選值是Enabled和Disabled;另外一種是Validation,它表示是否對表中現有的數據是否進行驗證,可選值是Validate和NoValidate。

toad create constraint step 2

對于上面這兩種狀態,有4種組合,下面是對著四種的詳細介紹。

ENABLE VALIDATE is the same as ENABLE. The constraint is checked and is guaranteed to hold for all rows.

ENABLE NOVALIDATE means that the constraint is checked, but it does not have to be true for all rows. This allows existing rows to violate the constraint, while ensuring that all new or modified rows are valid.

In an ALTER TABLE statement, ENABLE NOVALIDATE resumes constraint checking on disabled constraints without first validating all data in the table.

DISABLE NOVALIDATE is the same as DISABLE. The constraint is not checked and is not necessarily true.

DISABLE VALIDATE disables the constraint, drops the index on the constraint, and disallows any modification of the constrained columns.

約束的設置還有一個延遲性設置,默認是非延遲的,也就是Initially Immediate,這種情況下任何的修改都會進行校驗,另外一種是延遲的,也就是Intially Deferred,會在所有修改完成后commit的時候校驗,進而引發回滾。

 

責任編輯:迎迎 來源: 中國IT實驗室
相關推薦

2011-08-10 15:38:12

ConstraintOracle

2011-07-20 12:34:49

SQLite數據庫約束

2009-03-23 10:11:59

Oracle數據庫唯一約束

2011-08-10 16:01:11

OracleConstraint

2010-04-23 09:23:44

Oracle 數據庫

2011-03-10 13:24:26

2015-08-21 12:59:38

Oracle數據庫

2011-03-16 08:54:45

Oracle數據庫索引

2011-05-19 13:25:14

Oracle數據庫

2011-04-11 09:39:46

Oracle約束

2011-03-29 10:47:49

ORACLE數據庫

2010-04-02 13:59:08

Oracle數據庫

2010-04-19 16:01:54

2010-06-17 12:59:07

Oracle

2011-03-07 13:30:53

Oracle數據庫

2010-04-14 15:14:11

Oracle數據庫

2011-05-24 14:27:42

2010-10-28 15:56:21

ORACLE數據庫設置

2011-10-09 09:38:03

OracleNoSQL

2010-08-10 15:02:18

Oracle認證數據庫
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 久久看精品 | 色视频在线观看 | 成人欧美一区二区三区黑人孕妇 | 青草福利 | 久久福利电影 | 国产1区2区3区 | 久久一区二 | 日韩视频在线一区二区 | 色天堂影院 | 天天综合久久 | 久久久久久久国产精品影院 | 国产精品久久久久久久久久免费看 | 亚洲综合在线视频 | 成人免费影院 | 国产精品久久久久久久久 | 亚洲二区在线 | 亚洲欧美在线观看 | 成人在线视频观看 | 久久中文字幕电影 | 国产精品久久久久久久久久三级 | 亚洲天堂av在线 | 国外成人在线视频 | 亚洲成人自拍 | 日韩免费视频一区二区 | 97久久国产| 国产成人综合一区二区三区 | 亚洲激情网站 | 青青久久av北条麻妃海外网 | 男人视频网站 | 久久久久免费精品国产 | 日日操视频 | 免费国产一区二区视频 | 国产色爽| 久久精品一区 | 偷偷操视频 | 久久久蜜桃一区二区人 | 午夜电影网站 | 精品久久久久香蕉网 | 一区二区三区在线看 | 久久国产精品-国产精品 | 视频一区二区在线观看 |