0

I am using sqlite DB with SQLite Expert personal as the Admin tool to design and add data.

My question is, how do I limit value of INT fields to a 16bit so that user cannot add number > 65535?

Please suggest any other better SQLite admin tool if what I am using is not great.

thanks

1 Answer 1

2

You can create the table in question with a constraint;

CREATE TABLE Test ( col1 INT, CONSTRAINT my_limit CHECK (col1<65536) );

which won't let you insert numbers larger than 65535 in that column. (you may want to remember to limit below 0 also if that's a requirement)

Sadly you can't add a constraint to an existing table in SQLite.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks a lot, that worked. Btw How do I limit strings to list of pre-defined values only?
@2ndlife Just create a constraint in the same way; create table Test (value varchar(32), CONSTRAINT my_limit CHECK (value='YES' OR value='NO'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.