Integrity Constraints

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • njames
    New Member
    • Jun 2007
    • 2

    Integrity Constraints

    There are two doubts regarding integrity constraints :

    1) Can the constraints "NOT NULL" and "DEFAULT" be assigned at table level ? i have tried using the syntax of CHECK constraint at table level,

    Code:
     constraint con1 not null (emp_id));
    and also the syntax of PRIMARY KEY constraint at table level,

    Code:
     not null (emp_id));
    i tried same syntax for DEFAULT constraint too.but it doesn't work. please let me know if both constraints are possible at table level.

    2) i am not sure if this question is related to integrity constraints...h onestly, i don't know even its meaning .....What is LMS ? is it related to locking tables ?

    i tried searching for both my doubts , didn't help.

    Thanks for reading the post.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try thsi piece of code

    Code:
    CREATE TABLE STUDENT 
    (
    STUDENT _ID NUMBER(3) CONSTRAINT S_ID CHECK (STUDENT _ID > 0),
    STUDENT _NAME CHAR(30) CONSTRAINT S_NAME NOT NULL,
    MARKS_COUNT NUMBER(6),
    CONSTRAINT STUDENT _PRIME PRIMARY KEY (STUDENT _ID))
    Hope it helps you .

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Column level constraints go directly after the column definition to which they refer and the table level constraints go after the last column definition.

      NOT NULL constraint cant be defined at table label so as DEFAULT.

      Comment

      Working...