On Wed, 25 Mar 2009 13:06:24 -0400, "Wilson, Ron P"
<ronald.wil...@tycoelectronics.com> wrote:

>Cool!  I didn't think of doing that.  
>I presume this would incur a performance hit
>on insert/update to check the constraint 

Not much. The column data is _dynamically_ typed, 
so SQLite will determine the type of each 
value offered anyway.

>and sqlite3_prepare* would return SQLITE_CONSTRAINT 
>if the check failed.  Right?

Wrong. sqlite3_prepare* doesn't know the data you are going
to offer with sqlite3_bind*. The same 'prepared' statement
can be used with valid and invalid data.

CONSTRAINT violations will be discovered during VM execution
of your INSERT / UPDATE statements.
See how it works with something like:

EXPLAIN INSERT ....... ;


>RW
>
>Ron Wilson, S/W Systems Engineer III, Tyco Electronics, 434.455.6453
>
>
>
>
>
>If you want to place a restriction on a column such that it will only
>
>hold an integer (for example) you can use a CHECK constraint.
>
>
>
>      CREATE TABLE example1(x INTEGER CHECK( typeof(x)='integer' ));
>
>
>
>D. Richard Hipp
>
>d...@hwaci.com
>
>
>
>
>
>
>
>_______________________________________________
>
>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
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to