By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,806 Members | 1,841 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,806 IT Pros & Developers. It's quick & easy.

Query

P: 1
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
Sep 25 '09 #1
Share this Question
Share on Google+
2 Replies


100+
P: 384
Are you doing this directly on the database or through an application/website?
Sep 25 '09 #2

ssnaik84
100+
P: 149
You can create a check constraint

Expand|Select|Wrap|Line Numbers
  1. create table testrule
  2. (srno int)
  3.  
  4. ALTER TABLE testrule 
  5. ADD CONSTRAINT myconstraint CHECK (srno LIKE '[1-5]' );
  6.  
  7. insert into testrule values (2)
  8. insert into testrule values (7)
  9.  
  10. select * from testrule
Sep 25 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.