Search code examples
sqliteprepared-statementalter-table

Can I prepare "ALTER TABLE ? RENAME TO ?;" in SQLite?


When trying to prepare statement ALTER TABLE ? RENAME TO ?; in SQLite 3.7.17 via DBD-SQLite-1.40 in order to upgrade the schema being used, I got an error message:

near "?": syntax error

So I wonder whether using $dbh->prepare() the reason for the "syntax" error?


Solution

  • No, you cannot:

    1. Placeholders cannot be used for table and column names
    2. Commands manipulating the table structure (DDL) cannot be prepared.