Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krvmadhu
    New Member
    • Sep 2009
    • 1

    Query

    I want to insert some particular values to a table

    for ex:
    In a table for a column i want to insert only values from 1,2,3,4,5.It sholud not allow to enter 6,7.... or any value
  • ziycon
    Contributor
    • Sep 2008
    • 384

    #2
    Are you doing this directly on the database or through an application/website?

    Comment

    • ssnaik84
      New Member
      • Aug 2009
      • 149

      #3
      You can create a check constraint

      Code:
      create table testrule
      (srno int)
      
      ALTER TABLE testrule 
      ADD CONSTRAINT myconstraint CHECK (srno LIKE '[1-5]' );
      
      insert into testrule values (2)
      insert into testrule values (7)
      
      select * from testrule

      Comment

      Working...