When you specify a unique constraint on one or more columns, Oracle implicitly creates an index on the unique key. See Collation Sensitivity of Constraints for more details. Unique constraints are sensitive to declared collations of their key columns. However, two rows that contain nulls for one or more key columns and the same combination of values for the other key columns violate the constraint. Any row that contains nulls in all key columns automatically satisfies the constraint. To satisfy a composite unique key, no two rows in the table or view can have the same combination of values in the key columns. However, the unique key made up of a single column can contain nulls. To satisfy a unique constraint, no two rows in the table can have the same value for the unique key. You must define a composite unique key out of line. When you define a unique constraint out of line, you must also specify one or more columns. When you define a unique constraint inline, you need only the UNIQUE keyword. A composite unique key designates a combination of columns as the unique key. You cannot define view constraints on attributes of an object column.Ī unique constraint designates a column as a unique key. You can specify only unique, primary key, and foreign key constraints on views, and they are supported only in DISABLE NOVALIDATE mode. However, you can enforce constraints on views through constraints on base tables. Oracle Database does not enforce view constraints. All other constraints can be declared either inline or out of line.Ĭonstraint clauses can appear in the following statements: NOT NULL constraints must be declared inline. This is called out-of-line specification. This is called inline specification.Īs part of the table definition. You can define constraints syntactically in two ways:Īs part of the definition of an individual column or attribute. A REF constraint lets you further describe the relationship between the REF column and the object it references. 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. The six types of integrity constraint are described briefly here and more fully in " Semantics":Ī 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. Oracle Database lets you create six types of constraints and lets you declare them in two ways. Use a constraint to define an integrity constraint-a rule that restricts the values in a database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |