[英]PostgreSQL is it possible to parameterize the table name used in a query?
In PostgreSQL, is it possible to parameterize the table name used in a query?在 PostgreSQL 中,是否可以参数化查询中使用的表名?
Think of parameters as a replacement for scalar values only.仅将参数视为标量值的替代品。 Use one parameter in the place where you could use one string literal or numeric literal.
在可以使用一个字符串文字或数字文字的地方使用一个参数。
You cannot use parameters for other parts of an SQL query:您不能将参数用于 SQL 查询的其他部分:
IN (...)
predicate.IN (...)
谓词中。 Each value in the list would need an individual parameter. All those parts of the SQL query must be fixed by the time the query is parsed during prepare()
. SQL 查询的所有这些部分必须在
prepare()
期间解析查询时修复。 If a client library supports "parameters" for identifiers, it's really doing string-interpolation into the SQL query before the query is parsed.如果客户端库支持标识符的“参数”,它实际上是在解析查询之前对 SQL 查询进行字符串插值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.