>From the documentation http://sqlite.org/lang_altertable.html
The ADD COLUMN syntax is used to add a new column to an existing table.
...
* If a NOT NULL constraint is specified, then the column must have a
default value other than NULL.
Regards,
Noah
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Alex Ousherovitch
Sent: Monday, March 16, 2009 11:48 AM
To: [email protected]
Subject: Re: [sqlite] Adding a NOT NULL column fails on empty table
We want this operation to work when it can and fail when it has to. In
some cases the user will specify NOT NULL and in others they won't. Of
course we can drop and recreate the table but then we have to examine
the request to see if the field has the NOT NULL constraint and then
test to see if there is data in the table. It's not terribly difficult
but it leads to a more complicated set of code paths than just giving it
a shot and relying on SQLite to handle it correctly.
> Igor Tandetnik itandetnik at mvps.org
<mailto:sqlite-users%40sqlite.org?Subject=%5Bsqlite%5D%20Adding%20a%20NO
T%20NULL%20column%20fails%20on%20empty%20table&In-Reply-To=>
> Mon Mar 16 18:23:40 GMT 2009
> Can't you just drop the table and create a new one? As the table is
> empty, you won't be losing any data.
> Igor Tandetnik
From: Alex Ousherovitch
Sent: Monday, March 16, 2009 11:13 AM
To: '[email protected]'
Subject: Adding a NOT NULL column fails on empty table
Hello list,
The attempts to add a NOT NULL column on an empty table
ALTER TABLE tbl_name ADD COLUMN col_name blob NOT NULL
fail with the following error message:
Cannot add a NOT NULL column with default value NULL
As I understand, many other systems allow it when the table has no
records.
Is it a bug or a feature in SQLite?
Thank you,
Alex
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
CONFIDENTIALITY NOTICE:
This message may contain confidential and/or privileged information. If you are
not the addressee or authorized to receive this for the addressee, you must not
use, copy, disclose, or take any action based on this message or any
information herein. If you have received this message in error, please advise
the sender immediately by reply e-mail and delete this message. Thank you for
your cooperation.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users