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

Oracle數(shù)據(jù)庫約束

數(shù)據(jù)庫 Oracle
Oracle數(shù)據(jù)庫是甲骨文公司的一款關(guān)系數(shù)據(jù)庫管理系統(tǒng)。到目前仍在數(shù)據(jù)庫市場上占有主要份額。下文中主要為大家講解Oracle數(shù)據(jù)庫的約束。

Oracle數(shù)據(jù)庫是大家平時的工作中經(jīng)常會用到的,本文將為大家?guī)鞳racle數(shù)據(jù)庫約束的講解,希望對大家能夠有所幫助。

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

可以從TOAD的設(shè)置上,很容易看到約束分為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) 的約束來實現(xiàn)。

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

toad create constraint step 2

對于上面這兩種狀態(tài),有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.

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

 

責(zé)任編輯:迎迎 來源: 中國IT實驗室
相關(guān)推薦

2011-08-10 15:38:12

ConstraintOracle

2011-07-20 12:34:49

SQLite數(shù)據(jù)庫約束

2009-03-23 10:11:59

Oracle數(shù)據(jù)庫唯一約束

2011-08-10 16:01:11

OracleConstraint

2011-05-19 13:25:14

Oracle數(shù)據(jù)庫

2011-03-16 08:54:45

Oracle數(shù)據(jù)庫索引

2010-04-23 09:23:44

Oracle 數(shù)據(jù)庫

2011-03-10 13:24:26

2015-08-21 12:59:38

Oracle數(shù)據(jù)庫

2011-03-29 10:47:49

ORACLE數(shù)據(jù)庫

2011-04-11 09:39:46

Oracle約束

2010-10-28 15:56:21

ORACLE數(shù)據(jù)庫設(shè)置

2011-10-09 09:38:03

OracleNoSQL

2010-08-10 15:02:18

Oracle認證數(shù)據(jù)庫

2023-09-08 08:44:09

Oracle數(shù)據(jù)庫

2010-04-02 13:59:08

Oracle數(shù)據(jù)庫

2010-04-19 16:01:54

2010-06-17 12:59:07

Oracle

2011-03-07 13:30:53

Oracle數(shù)據(jù)庫

2010-04-14 15:14:11

Oracle數(shù)據(jù)庫
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 国产99视频精品免费播放照片 | 国产免费观看一级国产 | 国产区精品视频 | 国产日韩欧美 | 国内自拍真实伦在线观看 | 国产乱码精品1区2区3区 | 99久久精品国产麻豆演员表 | 精品av| 亚洲男女视频在线观看 | 精品国产乱码久久久久久丨区2区 | 亚洲最大av网站 | 午夜成人免费视频 | 色久影院| 国产日韩一区二区三免费高清 | 三级特黄特色视频 | 免费成人av | 北条麻妃99精品青青久久 | 亚洲国产欧美91 | 伊人二区| 欧美一级视频免费看 | 国内久久精品 | 国产高清精品网站 | 天天av网 | 久久精品 | 亚洲一二三区免费 | 久久精选| 国产色| 欧美理论| 激情五月综合网 | 最近日韩中文字幕 | 中文字幕一区二区三区日韩精品 | 亚洲三区视频 | 九九伦理片 | 一区二区视频在线 | 99热精品在线观看 | 国产高清免费 | 国产精品日韩在线观看 | 日日干日日 | 精品免费国产视频 | 午夜在线小视频 | 日韩精品在线免费观看视频 |