[Tutor] How to test for the existence of a table in a sqlite3 db?

Alan Gauld alan.gauld at yahoo.co.uk
Thu Oct 19 03:26:21 EDT 2017


On 18/10/17 21:09, Albert-Jan Roskam wrote:
> 
> On Oct 16, 2017 15:12, Neil Cerutti <neilc at norwich.edu> wrote:

>> sqlite3 module. In sqlite modifying table definitions is limited
>> to the simple addition of a new row of data. 

> 
> Really? How so? I used ALTER TABLE ADD COLUMN the other day, 

I think Neil meant that Sqlite ALTER is limited to adding *columns*.
Adding rows would be an INSERT not an ALTER.

The only other thing SQLite ALTER can do is change the table name.

But most SQLs allow you to modify existing column definitions too,
such as add defaults or conditions. You can't do that in SQLite,
you need to create a new table (TEMP)and copy the data  across
then drop the old table and rename the new one to the old.
All a bit tedious.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list