Table names cannot be sent as parameters. Table names are resolved during parsing, as they are necessary for planning and such things. Parameters are replaced only when the executor (or, if necessary, the optimizer) takes time.
So, you will need to use a string replacement. Of course, this is not a security problem (or even the risk of becoming one) if the table name comes from a constant in your class.
But if you create a table name from user input, you need to be very careful. But usually, if you need to build a table name from user input, something is poorly designed in the database in the first place and should be fixed (yes, of course, there are exceptions).
Magnus hagander
source share