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
Scoping Within the similar scope, all the declared identifiers should be unique. So, even if their datatypes differ, the variables and parameters cannot share the similar name.

Collection Methods:   The collection method is a built-in function or procedure which operates on the collections and is called using the dot notation. The methods like the C

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

Declarations in SQL Your program stores values in the variables and constants. As the program executes, the value of the variables can change, but the values constants cannot.

Project Description: I want somebody who can help me with an idea that I have been working on for a few months now. The person will require extensive knowledge of warcraft 3 PvP

Create a procedure named STATUS_SHIP_SP that allows a company to employee in the Shipping Department to update the status of an order to add shipping information. The BB_BASKETSTAT

Restriction and AND - SQL Restriction is available via the WHERE operator, and so it is in SQL. However, by Example showing how a certain simple restriction can be expressed u

Project Description: I am looking to change FullCalendar to add/delete sql server data when events are removed or dropped from Calendar. Events should only be included by dra

Bulk Fetching The illustration below shows that you can bulk-fetch from a cursor into one or more collections: DECLARE TYPE NameTab IS TABLE OF emp.ename%TYPE; TYPE S

Committing and Rolling Back The COMMIT and ROLLBACK end the active autonomous transaction but do not exit the autonomous routine. As the figure shows, if one transaction ends,