Why can’t a bound SQLite parameter stand in for a table name?
Quick answer
A bound parameter supplies a value to a prepared SQL statement; it does not rewrite the statement’s SQL syntax. SQLite’s C interface allows parameters where literal values are permitted, not where a table or column name must be written. [S1] If an application needs to choose a table, select the identifier from a controlled set of valid choices, then bind ordinary data values separately. Check your language wrapper’s documentation for its API-specific behavior. [S2]
The question, the details, the next step.
A practical checklist
Identify table or column choices assembled dynamically.
Confirm each dynamic identifier resolves only to an explicit, controlled set of valid choices.
Bind ordinary data values separately from SQL identifiers.
Reject or handle choices that do not match the approved mapping.
Check placeholder and binding behavior in the documentation for your SQLite language wrapper.
Review tests for approved choices, unsupported choices, and representative bound values.
A few more useful answers
Can a parameter represent a column name instead of a table name?
No, not in SQLite’s C prepared-statement interface: parameters stand for literal values, not table or column identifiers. [S1] Use a controlled identifier choice and verify your wrapper’s details.
What are SQLite placeholders for?
They mark positions for values supplied when binding to a prepared statement. The C API documents forms including ?, ?NNN, :VVV, @VVV, and $VVV. [S2]
Sources
References used for this guide.
- [S1] An Introduction to the SQLite C/C++ Interface sqlite.org · Checked
- [S2] SQLite C Interface: Binding Values to Prepared Statements sqlite.org · Checked
