[sqlite] ALTER TABLE .. ADD COLUMN .. IF NOT EXISTS ..?

2014-12-16 Thread Nico Williams
I have a habit of putting schema definitions in a file that's always safe to read and execute against a DB connection. This means that I DROP some things IF EXISTS and CREATE all things IF NOT EXISTS. But if I have to ALTER TABLE... there's no IF NOT EXISTS .. equivalent for ALTER TABLE. Funny

Re: [sqlite] ALTER TABLE .. ADD COLUMN .. IF NOT EXISTS ..?

2014-12-16 Thread Simon Slavin
On 16 Dec 2014, at 10:40pm, Nico Williams n...@cryptonector.com wrote: I have a habit of putting schema definitions in a file that's always safe to read and execute against a DB connection. This means that I DROP some things IF EXISTS and CREATE all things IF NOT EXISTS. But if I have to

Re: [sqlite] ALTER TABLE .. ADD COLUMN .. IF NOT EXISTS ..?

2014-12-16 Thread Nico Williams
On Tue, Dec 16, 2014 at 11:40:22PM +, Simon Slavin wrote: If 'ALTER TABLE ... ADD COLUMN ...' fails it fails harmlessly, with But it doesn't fail so harmlessly: $ sqlite3 db 'alter table toy add column foo text; select 5;' || echo fail SQL Error: duplicate column name: foo fail $ Note

Re: [sqlite] ALTER TABLE ... RENAME and indices.

2013-08-12 Thread Richard Hipp
On Mon, Aug 12, 2013 at 4:34 PM, Scott Hess sh...@google.com wrote: I had been attempting to write some code like this: CREATE TABLE t (x); CREATE INDEX t_x ON t(x); -- bunch of operations over a long period. -- now we want to run an expiration pass: BEGIN; ALTER TABLE t RENAME TO t_old;

[sqlite] Alter table constraint question

2012-09-09 Thread Andrea Peri
Hi, I'm an user of sqlite with the spatial extension spatialite. I see the sqlite db allow to define a constraints when are in the creating phase of the table. But is not possible to add or drop a constraint after the table is created. In the GIS data the availability of the constraints is a

Re: [sqlite] Alter table constraint question

2012-09-09 Thread Peter Haworth
AM, sqlite-users-requ...@sqlite.org wrote: Message: 9 Date: Sun, 9 Sep 2012 11:19:21 +0200 From: Andrea Peri aperi2...@gmail.com To: sqlite-users@sqlite.org Subject: [sqlite] Alter table constraint question Message-ID: CABqTJk-URe6sGd143HQ_9pso1C8= nxznqt0f+jyqmnyqbda

Re: [sqlite] Alter table constraint question

2012-09-09 Thread Peter Aronson
As pointed out, there are products out there that will add or drop constraints (by doing all the tedious table creation/rename/drop under the covers) for SQLite. The other approach is to do what SpatiaLite does in general -- use triggers instead of check constraints but for the same purpose

[sqlite] Alter table: number size

2012-02-28 Thread Marco Turco
Hi all, I need to alter a field from smallint(1) to smallint(2), is there to do this using ALTER TABLE ? Thanks in advance Marco ___ sqlite-users mailing list sqlite-users@sqlite.org

Re: [sqlite] Alter table: number size

2012-02-28 Thread Richard Hipp
On Tue, Feb 28, 2012 at 7:14 AM, Marco Turco m.tu...@softwarexp.co.ukwrote: Hi all, I need to alter a field from smallint(1) to smallint(2), No you don't; not unless your application or the wrapper you are using are reading the schema or datatypes separately. SQLite itself makes no

[sqlite] ALTER TABLE

2012-02-06 Thread Bill McCormick
Is there no way to force columns added to a table with alter table to be added at certain column positions? Alternatively, if there is some way to save the data in an existing table; drop the table; re-create the table with the desired schema; and then reload the data, this would be useful as

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Puneet Kishor
On Feb 6, 2012, at 9:36 AM, Bill McCormick wrote: Is there no way to force columns added to a table with alter table to be added at certain column positions? Alternatively, if there is some way to save the data in an existing table; drop the table; re-create the table with the desired

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Gerry Snyder
On 2/6/2012 8:36 AM, Bill McCormick wrote: Is there no way to force columns added to a table with alter table to be added at certain column positions? Alternatively, if there is some way to save the data in an existing table; drop the table; re-create the table with the desired schema; and

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Bill McCormick
Gerry Snyder wrote, On 2/6/2012 9:48 AM: On 2/6/2012 8:36 AM, Bill McCormick wrote: Is there no way to force columns added to a table with alter table to be added at certain column positions? Alternatively, if there is some way to save the data in an existing table; drop the table; re-create

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Gerry Snyder
On 2/6/2012 9:22 AM, Bill McCormick wrote: Sorry, I should have mentioned that I did see that, but it doesn't quite fit my application. I need a script that doesn't care what the existing table looks like. In my situation, I may have dozens of databases among different locations, perhaps not

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Black, Michael (IS)
AM To: General Discussion of SQLite Database Subject: EXT :Re: [sqlite] ALTER TABLE On 2/6/2012 9:22 AM, Bill McCormick wrote: Sorry, I should have mentioned that I did see that, but it doesn't quite fit my application. I need a script that doesn't care what the existing table looks like. In my

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Nico Williams
On Mon, Feb 6, 2012 at 9:36 AM, Bill McCormick wpmccorm...@gmail.com wrote: Is there no way to force columns added to a table with alter table to be added at certain column positions? Alternatively, if there is some way to save the data in an existing table; drop the table; re-create the

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Bill McCormick
Nico Williams wrote, On 2/6/2012 12:44 PM: On Mon, Feb 6, 2012 at 9:36 AM, Bill McCormickwpmccorm...@gmail.com wrote: Is there no way to force columns added to a table with alter table to be added at certain column positions? Alternatively, if there is some way to save the data in an existing

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Ryan Johnson
On 06/02/2012 1:59 PM, Bill McCormick wrote: Nico Williams wrote, On 2/6/2012 12:44 PM: On Mon, Feb 6, 2012 at 9:36 AM, Bill McCormickwpmccorm...@gmail.com wrote: Is there no way to force columns added to a table with alter table to be added at certain column positions? Alternatively, if

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Tim Streater
On 06 Feb 2012 at 19:31, Ryan Johnson ryan.john...@cs.utoronto.ca wrote: On 06/02/2012 1:59 PM, Bill McCormick wrote: The order is not important. What is important is that I come up with some way to manage version updates. I've tried doing something similar in the past using an alter tables

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Nico Williams
I'm pretty sure that the user_version pragma is considered stable. That said, if your application is in full control of the DB then you could just check the exact create statements logged in sqlite_master (this is probably less stable, ironically enough).

Re: [sqlite] ALTER TABLE

2012-02-06 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/02/12 12:50, Tim Streater wrote: Can that [pragma user_version] be relied upon, though? It is used by both Firefox and Android. The actual value is stored in the SQLite header. It would be astonishing and unprecedented for the SQLite team to

[sqlite] alter table add column

2011-05-31 Thread Fabio Spadaro
Alter table add column command drop data from table. Can you keep the data or should I store the data before the alter and then put them in the table? -- Fabio Spadaro www.fabiospadaro.com ___ sqlite-users mailing list sqlite-users@sqlite.org

Re: [sqlite] alter table add column

2011-05-31 Thread Mr. Puneet Kishor
On May 31, 2011, at 10:11 AM, Fabio Spadaro wrote: Alter table add column command drop data from table. Can you keep the data or should I store the data before the alter and then put them in the table? ALTER TABLE ADD COLUMN does not drop data from the table.

Re: [sqlite] alter table add column

2011-05-31 Thread Stephan Beal
On Tue, May 31, 2011 at 5:11 PM, Fabio Spadaro fabiolinos...@gmail.comwrote: Alter table add column command drop data from table. Can you keep the data or should I store the data before the alter and then put them in the table? http://www.sqlite.org/lang_altertable.html says: The

Re: [sqlite] alter table add column

2011-05-31 Thread Fabio Spadaro
Hi 2011/5/31 Stephan Beal sgb...@googlemail.com On Tue, May 31, 2011 at 5:11 PM, Fabio Spadaro fabiolinos...@gmail.com wrote: Alter table add column command drop data from table. Can you keep the data or should I store the data before the alter and then put them in the table?

Re: [sqlite] alter table add column

2011-05-31 Thread Stephan Beal
On Tue, May 31, 2011 at 6:09 PM, Fabio Spadaro fabiolinos...@gmail.comwrote: To recap: Step 1: alter table pippo rename to fabio - ok step 2: insert into fabio (field1) values ('1 ') - ko OperationalError: no such table main.pippo Step 3: alter table add column fabio field2 integer null

Re: [sqlite] alter table add column

2011-05-31 Thread Simon Slavin
On 31 May 2011, at 5:09pm, Fabio Spadaro wrote: Step 1: alter table pippo rename to fabio - ok step 2: insert into fabio (field1) values ​​('1 ') - ko OperationalError: no such table main.pippo How does step 2 know the name 'pippo' ? You don't seem to supply it in the command. Simon.

Re: [sqlite] ALTER TABLE and INTEGER PRIMARY KEY.

2007-08-15 Thread Scott Hess
To: [EMAIL PROTECTED] Cc: sqlite-users@sqlite.org Subject: Re: [sqlite] ALTER TABLE and INTEGER PRIMARY KEY. On 8/14/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Scott Hess [EMAIL PROTECTED] wrote: I was getting ready to checkin the rowid-versus-fts2 fix, and wanted to add one last

[sqlite] ALTER TABLE and INTEGER PRIMARY KEY.

2007-08-14 Thread Scott Hess
I was getting ready to checkin the rowid-versus-fts2 fix, and wanted to add one last bit, to upgrade older tables. Unfortunately, code of the form: ALTER TABLE x_segments ADD id INTEGER PRIMARY KEY; is documented as not supported. http://www.sqlite.org/lang_altertable.html . As far as I can

Re: [sqlite] ALTER TABLE and INTEGER PRIMARY KEY.

2007-08-14 Thread drh
Scott Hess [EMAIL PROTECTED] wrote: I was getting ready to checkin the rowid-versus-fts2 fix, and wanted to add one last bit, to upgrade older tables. Unfortunately, code of the form: ALTER TABLE x_segments ADD id INTEGER PRIMARY KEY; is documented as not supported.

Re: [sqlite] ALTER TABLE and INTEGER PRIMARY KEY.

2007-08-14 Thread Joe Wilson
--- Scott Hess [EMAIL PROTECTED] wrote: This may mean that I'll need to branch fts2 to fts3 and deprecate fts1/2 as being not safe for use. If the code is going to have to create new tables and populate them, then there's not a lot of gain versus just having the developer do that. Is it a

Re: [sqlite] ALTER TABLE and INTEGER PRIMARY KEY.

2007-08-14 Thread Joe Wilson
--- [EMAIL PROTECTED] wrote: Scott Hess [EMAIL PROTECTED] wrote: I was getting ready to checkin the rowid-versus-fts2 fix, and wanted to add one last bit, to upgrade older tables. Unfortunately, code of the form: ALTER TABLE x_segments ADD id INTEGER PRIMARY KEY; is

Re: [sqlite] ALTER TABLE and INTEGER PRIMARY KEY.

2007-08-14 Thread Scott Hess
On 8/14/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Scott Hess [EMAIL PROTECTED] wrote: I was getting ready to checkin the rowid-versus-fts2 fix, and wanted to add one last bit, to upgrade older tables. Unfortunately, code of the form: ALTER TABLE x_segments ADD id INTEGER

Re: [sqlite] ALTER TABLE and INTEGER PRIMARY KEY.

2007-08-14 Thread drh
Scott Hess [EMAIL PROTECTED] wrote: It appears that you can set PRAGMA writable_schema=ON; Then do a manual UPDATE of the sqlite_master table to insert an id INTEGER PRIMARY KEY into the SQL for the table definition. I tried it and it seems to work. But it is dangerous. If you

RE: [sqlite] ALTER TABLE and INTEGER PRIMARY KEY.

2007-08-14 Thread Samuel R. Neff
:[EMAIL PROTECTED] Sent: Tuesday, August 14, 2007 8:22 PM To: [EMAIL PROTECTED] Cc: sqlite-users@sqlite.org Subject: Re: [sqlite] ALTER TABLE and INTEGER PRIMARY KEY. On 8/14/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Scott Hess [EMAIL PROTECTED] wrote: I was getting ready to checkin the rowid

[sqlite] ALTER TABLE ADD COLUMN - strange behaviour....Mac OSX

2007-06-03 Thread Mark Gilbert
Folks. I had been struggling to implement ALTER TABLE ADD COLUMN in my app to change the database structure. However I would continuously face a locked database error. After much experimentation I have come to a very very strange conclusion. In my app if I do this: -start app -open

Re: [sqlite] ALTER TABLE ADD COLUMN - strange behaviour....Mac OSX

2007-06-03 Thread Nuno Lucas
On 6/3/07, Mark Gilbert [EMAIL PROTECTED] wrote: Anyone have *any* idea what is happening ? I don't know nothing about MacOS, but you may want to check the result of sqlite3_close. It's possible it's not closing the database [1]. Regards, ~Nuno Lucas [1]

[sqlite] ALTER TABLE

2007-04-26 Thread BardzoTajneKonto
Is there a reason why ALTER TABLE ADD can add only one column? I'v changed the parser to allow any number of columns - I'm calling sqlite3AlterFinishAddColumn() for every column. It seems to work. Am I missing some problem, or nobody wanted more columns before? Wiktor Adamski

[sqlite] ALTER table command

2006-06-19 Thread Anish Enos Mathew
Hi all, Any body knows how to use ADD [COLUMN] in alter table command? I want to add a new field to my table. Can modify be used with alter command as in SQL? The information contained in, or attached to, this e-mail, contains confidential information and is intended solely for the use of

Re: [sqlite] ALTER table command

2006-06-19 Thread John Newby
http://www.sqlite.org/faq.html#q13 Hi, SQLite FAQ recommends creating temp tables and copying the data from the original table into it then deleting the old table then recreating the old table (with the desired new column) then copying the data back and deleting the temp table. On 19/06/06,

Re: [sqlite] ALTER table command

2006-06-19 Thread Clark Christensen
Assuming a schema like: create table t1 (a,b); Add another column, c alter table t1 add column c; -Clark - Original Message From: Anish Enos Mathew [EMAIL PROTECTED] To: sqlite-users@sqlite.org Sent: Monday, June 19, 2006 12:42:46 AM Subject: [sqlite] ALTER table command Hi all

[sqlite] Alter table to add a variable named column

2006-05-23 Thread Kevin Piciulo
I asked a similar question to this about accessing columns using a variable name, and the answer was you cannot. Sadly I cannot find the email explaining why so I'll ask this similar question: Can I add a column using a variable for the column name? Below is the prepare statement, which

Re: [sqlite] Alter table to add a variable named column

2006-05-23 Thread Dennis Cote
Kevin Piciulo wrote: Can I add a column using a variable for the column name? Below is the prepare statement, which is returning an error. sqlite3_prepare(m_dbDataBase, ALTER TABLE users ADD COLUMN ? varchar;, -1, stmt, NULL); I'm pretty sure my syntax is correct which leads me to

Re: [sqlite] Alter table to add a variable named column

2006-05-23 Thread Pam Greene
The workaround would be to build the statement some other way (sqlite3_mprintf(), for example) for each individual ALTER TABLE command. At that point you may want to use sqlite3_exec() instead of sqlite3_prepare(), depending on how you'll be using the statement. You'll also have to be more

[sqlite] alter table syntax ?

2006-02-23 Thread Doug Fajardo
( name ); sqlite alter table x1 add column ( phone ); SQL error: near alter: syntax error sqlite

Re: [sqlite] alter table syntax ?

2006-02-23 Thread Kurt Welgehausen
.help for instructions sqlite create table x1 ( name ); sqlite alter table x1 add column ( phone ); SQL error: near alter: syntax error sqlite There's no alter table statement in Sqlite v2.x; switch to v3 if you need it. Regards

[sqlite] ALTER TABLE Command restrictions

2005-11-22 Thread Robert Foster
Hi, I was just playing with ALTER TABLE, and it appears that you can only add 1 column with each command. Is this correct? If so, how hard would it be to enable adding multiple columns with the same command? Thanks, Robert Foster General Manager Mountain Visions P/L

Re: [sqlite] ALTER TABLE: Confusing documentation

2005-07-27 Thread Kurt Welgehausen
The docs are correct; you just have to read carefully. They say that you can rename, or add a new column to, an existing table. Regards

Re: [sqlite] ALTER TABLE: Confusing documentation

2005-07-27 Thread Tito Ciuro
On 27/07/2005, at 13:04, Kurt Welgehausen wrote: The docs are correct; you just have to read carefully. I have :-) They say that you can rename, or add a new column to, an existing table. No, it doesn't. It states that you can rename or add a new column to an existing table. Regards,

Re: [sqlite] alter table rename column

2005-05-07 Thread Will Leshner
On May 7, 2005, at 3:14 PM, Kurt Welgehausen wrote: SQLite's version of the ALTER TABLE command allows the user to rename, or add a new column to, an existing table. Aha. Ok. I get it now :)

[sqlite] ALTER TABLE ... ADD COLUMN crashes with too many columns

2005-03-29 Thread Andy Lutomirski
I can crash sqlite3 like this: % cat test.sql create table a (id INTEGER PRIMARY KEY); alter table a add column f1 TEXT; alter table a add column f2 TEXT; alter table a add column f3 TEXT; alter table a add column f4 TEXT; alter table a add column f5 TEXT; alter table a add column f6 TEXT; alter

Re: [sqlite] ALTER TABLE ... ADD COLUMN crashes with too many columns

2005-03-29 Thread D. Richard Hipp
On Tue, 2005-03-29 at 03:13 -0800, Andy Lutomirski wrote: I can crash sqlite3 like this: % cat test.sql create table a (id INTEGER PRIMARY KEY); alter table a add column f1 TEXT; alter table a add column f2 TEXT; alter table a add column f3 TEXT; alter table a add column f4 TEXT; alter

[sqlite] ALTER TABLE DROP/RENAME COLUMN?

2005-03-21 Thread chan wilson
Well, please allow me to congratulate to the release of 3.2.0 and many thanks to you guys! I was wondering whether it might be ALTER TABLE DROP/RENAME COLUMN in next release? _ MSN Messenger: http://messenger.msn.com/cn

[sqlite] ALTER TABLE substitute?

2005-01-06 Thread aleks ponjavic
What I want to do is drop and add columns, couldn't find something appropriate with sqlite, atleast it doesn't seem as ALTER TABLE works, how can I do it instead? Maybe it isn't possible? _ Express yourself instantly with MSN

Re: [sqlite] ALTER TABLE substitute?

2005-01-06 Thread Tito Ciuro
On 6 ene 2005, at 18:01, aleks ponjavic wrote: What I want to do is drop and add columns, couldn't find something appropriate with sqlite, atleast it doesn't seem as ALTER TABLE works, how can I do it instead? Maybe it isn't possible? Please check the archives. It's been discussed already:

[sqlite] ALTER TABLE statement?

2004-10-28 Thread Richard Boehme
Does anyone know if there are any plans for an ALTER TABLE statement? Not having it is a major issue in possibly adopting SQLite, as my boss feels that he can't easily alter the database with a GUI tool (the ones I've seen for SQLite don't handle it Thanks. Richard Boehme

Re: [sqlite] ALTER TABLE statement?

2004-10-28 Thread Cristiano Macaluso
Perhaps you search these examples ??? -Inserire una nuova colonna nel database (esempio completo). ATTENZIONE FARE PRIMA UNA COPIA DEL FILE-DATABASE sqlite prova #Crea una tabella sqlite create table t1(a text, b text); #Inizia la transazione sqlite BEGIN TRANSACTION; #Crea una tabella temporanea

Re: [sqlite] Alter Table?!

2003-10-25 Thread andr3a
I've implemented this sintax with few options on my PHP Class, if you're interested in syntax like this: ALTER TABLE tbl_name ADD column_name alter_specification [FIRST | AFTER column_name] or this: ALTER TABLE tbl_name DROP [COLUMN] col_name tell me. andr3a - Original Message - From: