Saturday, 19 November 2011


The CHECK CONSTRAINT can be applied to a table column by using CHECK validations in business rule
CHECK constraint must be specified as a logical expression theat evaluated either to TRUE or FALSE.

CHECK CONSTRAINT defined at the Column level

Syntax:
Column_Name Datatype (size) CHECK (Logical_Expression)
Example Statement:
CREATE TABLE Student_Detail
(
S_No number(2) CHECK (stu_no like 'j%'),
Name varchar(25)CHECK (name=upper(name)),
City varchar(25) CHECK (city IN ('Ahmedabad','Delhi','Mumbai'))
);
Create a table Student_Detail with following check constraints:
  • Data values being inserted into the column client_no must start with the capital letter 'j'.

  • Data values being inserted into the column name should be in upper case only.

  • Only aloe 'Ahmedabad','Delhi','Mumbai' as legitimate values for the column city.


  • CHECK CONSTRAINT defined at the Table level

    Syntax:
    CHECK (Logical_Expression)
    
    Example Statement:
    CREATE TABLE Student_Detail
    (
    S_No number(2),
    Name varchar(25),
    City varchar(25),
    CHECK (stu_no like 'j%'),
    CHECK (name=upper(name)),
    CHECK (city IN ('Ahmedabad','Delhi','Mumbai')
    );
    


    0 comments:

    Post a Comment

    TrainingHUB. Powered by Blogger.

    Total Pageviews

    THE BEST QTP TRAINING INSTITUTE IN HYDERABAD

    QTP Training in hyderabad

    Sql Tutorial

    Popular Posts

    Our Facebook Page

    TrainingHUB

    Followers