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
1- You can check attribute names from each table in DBF11 by running for example:  desc dbf11.Member;  desc dbf11.Agent;  desc dbf11.Producer; Because some attribute names in

Demonstrate your knowledge of PL/SQL programming by writing and thoroughly testing triggers and stored procedures associated with an e-commerce application that provides security l

UNION and OR - SQL SQL supports UNION explicitly but differently from the way it supports JOIN explicitly. As we have seen, JOIN is used exclusively within the FROM clause, su

Create a Oracle procedure to produce vertical output format when selecting rows from a database table.

On occasion, some of Brewbean's customers mistakenly leave an item out of a basket already checked out, so they create a new basket containing the missing items. However, they requ

Aggregate Operators SQL Supports all of the aggregate operators mentioned in the theory book and many more besides. The syntax, however, involves an unusual trick that SQL cal

%NOTFOUND The %NOTFOUND is logical, opposite of the %FOUND. The %NOTFOUND yields FALSE if the last fetch returned a row, or TRUE when the final fetch failed to return a row. I

Read-Only Operator (+) - SQL The term read-only operator to the mathematical term function. Here I just need to add that the SQL standard reserves the term function for read-

Pl/SQL Expressions The Expressions are constructed by using the operands and operators. An operand is a constant, literal, variable, or function call which contributes a value

At times, customers make mistakes in submitting their orders and call to cancel the order. Brewbean’s wants to create a trigger that automatically updates the stock level of all pr