Adding table constraints, PL-SQL Programming

Adding Table Constraints

ALTER TABLE ENROLMENT ADD CONSTRAINT NameNotNull

CHECK (Name IS NOT NULL) ;

ALTER TABLE ENROLMENT ADD CONSTRAINT PK_StudentId_CourseId

PRIMARY KEY (StudentId, CourseId) ;

  1. ALTER TABLE ENROLMENT specifies that the definition of base table ENROLMENT is to be modified in some way, such as adding or dropping a column, adding or dropping a constraint (among other things).
  2. ADD CONSTRAINT NameNotNull specifies that in fact a constraint is being added to the definition of ENROLMENT, and the name by which that constraint can subsequently be referred to is NameNotNull. For example, the name would be needed if the constraint were later to be dropped, or perhaps it could appear in an error message when an attempted update is rejected for violating that constraint. Similar comments apply to ADD CONSTRAINT PK_StudentId_CourseId.
  3. CHECK (Name IS NOT NULL) specifies a truth-valued expression, Name IS NOT NULL, that must be satisfied by each row of every table that is assigned to ENROLMENT. If the current value of ENROLMENT fails to satisfy this constraint, then the ALTER TABLE statement fails.
  4. PRIMARY KEY ( StudentId, CourseId ) used for constraint. Again, the ALTER TABLE statement fails if the constraint is not satisfied by the current value of ENROLMENT.
Posted Date: 1/18/2013 2:57:17 AM | Location : United States







Related Discussions:- Adding table constraints, Assignment Help, Ask Question on Adding table constraints, Get Answer, Expert's Help, Adding table constraints Discussions

Write discussion on Adding table constraints
Your posts are moderated
Related Questions
%FOUND Subsequent to a cursor or cursor variable is opened but before the first fetch, the %FOUND yields NULL. Afterward, it yields TRUE when the last fetch returned a row, or

Data Types in SQL - Decimal DECIMAL, NUMERIC, REAL, FLOAT and various other terms for various sets of rational numbers. When these key words are specified for the declared typ

Example of ADD CONSTRAINT in SQL Example: Alternative formulation for MAX_ENROLMENTS ALTER TABLE IS_ENROLLED_ON ADD CONSTRAINT MAX_ENROLMENTS CHECK ((SELECT COUNT (*)

Find the account numbers of all customers whose balance is more than 10,000 $

Keyword and Parameter Description: table_reference: This specifies a table or view that should be accessible when you execute the DELETE statement, and for that you must

Data Types in SQL - Character CHARACTER or, synonymously, CHAR, for character strings. When this type is to be the declared type of something (e.g., a column), the permissible

Lightweight system to provide and take info from workers in the field and office, have basic design outlined already just require build and implementation Desired Skills CSS,

Left and Right Joins LEFT OUTER JOIN can be used when you want to retrieve the data from the main table (table1) even if there is no match in other tables (table_2, table_3...

Scope Rules You cannot declare an exception twice in the similar block. Though, you can, declare the similar exception in 2 different blocks. The Exceptions declared in a bloc

The Package Body The package specification is implemented by the package body. That is, the package body has the definition of every cursor and the subprogram declared in the p