Hi Jay,
Creating a new db with the added constraint is not problem for me at this time. If I wanted to allows only values "yes" or "no" or "maybe" in the recommendation column would I do it like this when I created the table - recommendation varchar(4) CHECK(recommendation='yes' | recommendation='no' | recommendation='maybe' ) Thanks in advance -Chris ----- Original Message ----- From: "Jay A. Kreibich" <j...@kreibi.ch> To: "Jay A. Kreibich" <j...@kreibi.ch> Cc: "General Discussion of SQLite Database" <sqlite-users@sqlite.org> Sent: Sunday, July 11, 2010 7:16:10 AM Subject: Re: [sqlite] restricting values allowed in a column On Sun, Jul 11, 2010 at 09:12:09AM -0500, Jay A. Kreibich scratched on the wall: > On Sun, Jul 11, 2010 at 01:45:50PM +0000, c...@comcast.net scratched on the > wall: > > > I would like to restrict the values that are entered into > > the "recommendation" column. > > > > How would I state that at the time I create the column in that table? > > Using a CHECK constraint. > > > Since that table/column exists today without any restrictions, how > > do I alter it to restrict the values entered? > > You can't. You need to build a new table and copy the data over. I should have been more specific... You can't add a CHECK constraint to an existing table. You could also limit values with a set of BEFORE INSERT and BEFORE UPDATE triggers. Triggers can be added to an existing table. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users