Topic: whats wrong with this little query?
I am trying to run this little query on my sqlite database and ik keeps throwing a syntax error near ALTER
ALTER TABLE posts ADD COLUMN srcfile int;
Whats wrong with this?
You are not logged in. Please login or register.
PunBB Forums → Programming → whats wrong with this little query?
I am trying to run this little query on my sqlite database and ik keeps throwing a syntax error near ALTER
ALTER TABLE posts ADD COLUMN srcfile int;
Whats wrong with this?
Try integer, not int
same error
really strange...
could it be permition issues?
the file has permitions -rw-rw-r--
Don't you need to specify field size?
i think thats only for text fields
Check what version of SQLite you are using. ALTER TABLE ADD COLUMN did not come until SQLite 3.2.
i am using sqlite2 in fact.
That basically means i cant add a column to a table. Or am i missing something?
No, SQLite 2 has ALTER TABLE ADD COLUMN support. I have no idea what the problem is. Here's an example of what PunBB runs in the update script:
'ALTER TABLE '.$db->prefix.'users ADD dst INTEGER NOT NULL DEFAULT 0'
No, SQLite 2 has ALTER TABLE ADD COLUMN support.
That's incorrect. Alter table add column was not added until SQLite 3.2.0. See http://www.sqlite.org/changes.html.
Just to make sure I tried it out myself.
C:\>sqlite3
SQLite version 3.2.1
Enter ".help" for instructions
sqlite> create table sometable (col1 int, col2 int);
sqlite> alter table sometable add column col3 int;
sqlite>
C:\sqlite2_8_17>sqlite.exe
SQLite version 2.8.17
Enter ".help" for instructions
sqlite> create table sometable (col1 int, col2 int);
sqlite> alter table add column col3 int;
SQL error: near "alter": syntax error
sqlite>
2005 March 21 (3.2.0)
* Added support for ALTER TABLE ADD COLUMN.
Looks like that's right, as odd as them seems
any tips on how to perform a sqlite dump?
Create a new table with the columns you want, copy the contents of original table to the new one, drop the original, and then create another new table with the original name and copy the contents again. You can wrap the whole thing in a transaction if you want.
CREATE TEMPORARY TABLE mytable2 (col1, col2, col3);
INSERT INTO mytable2 SELECT col1, col2, NULL [or default value for col3] FROM mytable;
DROP TABLE mytable;
CREATE TABLE mytable (col1, col2, col3);
INSERT INTO mytable SELECT col1, col2, col3 FROM mytable2;
DROP TABLE mytable2;
thank you
PunBB Forums → Programming → whats wrong with this little query?
Powered by PunBB, supported by Informer Technologies, Inc.