Does anyone know how to change a column in SQLite and PostgreSQL to LONGTEXT?
I have done so in MySQL successfully with: "ALTER TABLE projects MODIFY description LONGTEXT;"
But this clause doesn't seem to work on SQLite. I tried hard to find documentation on PostgreSQL, but that site's format really makes people puke. SQLite's website is better but the only command I find relevant, alter table, doesn't seem to support changing column data type at all. ( infact, it doesn't开发者_运维问答 even allow changing column name!!!)
Thanks all!
For PostgreSQL, see the doc here (e.g., ALTER TABLE my_table ALTER COLUMN my_col text
).
The SQLite doc states
SQLite supports a limited subset of ALTER TABLE. The ALTER TABLE command in SQLite allows the user to rename a table or to add a new column to an existing table. It is not possible to rename a column, remove a column, or add or remove constraints from a table.
And I suppose changing the datatype of the column is out of scope. Probably to support this, you will need to do a SELECT * INTO ...
followed by DROP TABLE ...
and then create the table and run INSERT INTO ... SELECT * FROM ...
There's no point in declaring a LONGTEXT
column in SQLite. All type names with TEXT
or CHAR
or CLOB
in them are equivalent.
AFAIK, PostgreSQL does not have a limit on blobs, so don't worry.
SQLite3, apparently, doesn't care about the column type in this case (i.e. TEXT is the same as LONGTEXT)
I don't know what problem you have with Postresql documentation, it's quite good IMO.
To change a column datatype, here is the syntax.
Postgres supports arbitrary long strings (well, up to 2 GB or so) with the TEXT datatype.
精彩评论