Brothersoft.comWindows|Mac|Mobile|Games

|Message

Solve software problem quickly Share experience to help others Improve the ability of solving problem
Constraint Types in PL/SQL

11/07/2011 02:49 by MikeChin

First answer posted by Bentley907 at 11/07/2011 02:49
Add Your Answer
10~1000 characters in length CAPTCHA:
1 Answers
  • Bentley907
  • 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.

  • Was this answer helpful? 00 · 11/07/2011 02:49
Add Your Answer
10~1000 characters in length CAPTCHA:
Related Questions
Q:How to Rename a Primary Key

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)

Q:How to Make a Primary Key From a Table Query

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)

Q:How to Create a Primary Key

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)

Q:What Is an Access Key Violation?

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)

Q:CRM 4.0 Form Types

A:Customer Relationship Management, otherwise known as CRM, is a business strategy that a company follows to increase its profitability by inc...(more)

0 people are following

Ask a question now
Write a title for your question

XML Notepad

A simple application for browsing and editing XML documents. By Microsoft.
Latest version:2007
License:Freeware
OS:Windows Vista/2003/XP/2000
Total downloads:8,371
Rank:6 in XML
Download It

Share with friends

New features is coming

  • 1. Providing high-quality answers to be a verified Q&A expert
  • 2. Ask and answer questions to get Brothersoft credits

Added Successfully!

×

Are you sure to delete your answer?

NoYes

×

Are you sure to choose it as the best answer?

NoYes

×

Voted Successfully!

×

You can't vote for yourself

×

You can't choose your own answer

×