11/07/2011 02:49 by MikeChin
PL/SQL is a structured query language used primarily by the Oracle database management system. Constraints are rules or limits that records in a table must satisfy, made either at the time of a table's creation or added to the table later on. PL/SQL contains several types of constraints. Constraints in PL/SQL can apply to one or more fields.
Primary and Foreign Keys
A primary key uniquely identifies a record in a table. The field or fields that make up a primary key must all have values. If a primary key consists of more than one field, some fields may contain duplicate values in multiple records; however, the entire combined key fields must be unique to each record. A foreign key is a constraint that references a key in another table, often a primary key. The values in these fields must be equal. PL/SQL uses foreign keys to link multiple tables, such as a customer table and a table listing items purchased by those customers.
Unique Constraint
A unique constraint ensures that the field or fields to which the constraint applies in a record will have a different value from any other record in the table. The unique constraint is similar to a primary key, but fields with a unique constraint do not have to have values. If the constraint consists of more than one field, some fields can have null values as long as the combination of fields remains unique in the table.
Not Null Constraint
In PL/SQL, the "null" marker indicates a nonexistent value. A not null constraint specifies that a field in a record must have a value. Values such as 0 or a blank space are not equivalent to null and can be inserted into fields with a not null constraint. Create not null constraints on single fields only. If you try use PL/SQL to insert a record into a table but have a null value for a field with a not null constraint, Oracle will tell you it cannot insert null into the field and the insert query will fail.
Check Constraint
A check constraint lets you specify a condition new data must satisfy before an insert query can add the record to the table. When you create a check constraint in PL/SQL, you provide a name and then specify the check condition, for example to see if the value you want to insert is greater than some number or to ensure its length is within a certain range. You cannot define check constraints on views or include them in sub-queries.
A: Open the Microsoft Access Database program and the database file you want to edit. Double-click on the table name you want to edit from th...(more)
A: Create your basic table query. The table query consists of the "create" statement, the list of field names and the primary key designation. ...(more)
A: Identify the field to use as the unique key. Primary keys must be unique, so a field can be an auto-incremented number, or it can be a part ...(more)
A:Microsoft Access is a database system that organizes data into tables. The software allows you to link tables that are related. Key violatio...(more)
A:Customer Relationship Management, otherwise known as CRM, is a business strategy that a company follows to increase its profitability by inc...(more)
Added Successfully!
×Voted Successfully!
×You can't vote for yourself
×You can't choose your own answer
×