Solved QSQLQUERY can't execute "ALTER TABLE table_name DROP col_name
-
I want to delete column from SQLite table, then I found an answer.
It is not convenient to create a temporary table,so I hope to use "DROP".
But QSQLQUERY can't execute "ALTER TABLE test DROP test1".
I guess the version of qsqlite is too low. How can I address this issue? Thanks !
` -
ok, that is the reason then. Qt 5.15.1 comes with SQLite v3.32.3.
-
@Cedric-Niu
Firstly your syntax, if it works at all, is wrong. You would (presumably) needALTER TABLE test DROP COLUMN test1
.Assuming that too fails, what would you like anyone here to say about SQLite that is not covered in the stackoverflow/other references? Do you think people here miraculously know more than these? Upgrade your SQLite to one which supports the
DROP COLUMN
statement, or use the workaround which you do not find "convenient". Or change database. -
@JonB Thanks a lot.
ALTER TABLE test DROP COLUMN test1
It is also wrong.
`
In Qsqlquery it doesn't work, but it works in SQLite(3.35.0)ALTER TABLE test DROP test1
I don't know how to upgrade qsqlite.dll. So I only create a new table.
Thanks
-
Which Qt version are you using? Qt is bundling it's own build of SQLite so if you are not on newest Qt, you may be using SQLite older than 3.35.
-
@sierdzio PYSIDE2 5.15.1
Pyside6 may be using SQLite newer than 3.35...
-
ok, that is the reason then. Qt 5.15.1 comes with SQLite v3.32.3.
-
@sierdzio Ok, thanks. I have tested. Pyside2 can't do it, Pyside6 can do it.