On Apr 13, 2009, at 2:19 PM, jan wrote:
> Hi,
>
> is there a way to query the check constraints added to a column
> definition?
>
No.
Actually, SQLite does not support CHECK constraints assigned to
individual columns. Sure, you can include the CHECK constraint on an
individual column when you create the table, but what SQLite does
internally is coalesce all of the column CHECK constraints into one
big whole-table CHECK constraint. In other words, if you type this:
CREATE TABLE t1(
a INTEGER CHECK( a<10 ),
b VARCHAR(10) CHECK( length(b)>5
);
SQLite will actually implemented it as:
CREATE TABLE t1(
a INTEGER,
b TEXT,
CHECK( a<10 AND length(b)>5 )
);
To put it another way, all CHECK constraints on a table are gathered
together into a single boolean expression that is evaluated after
every INSERT or UPDATE and fails the operation if that single
expression is false. SQLite does not keep track of where the
individual terms in the CHECK constraint originally came from.
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users