I can do the following in MySQL, but would like to know how to do the equivalent in PostgreSQL. I have to wrap the query in a string because the table name is variable (can't just run CREATE TABLE
). This is all in a MySQL stored procedure / Postgres function.
SET @createTable = CONCAT("CREATE TABLE ", table_name, "(
id int(11) NOT NULL AUTO_INCREMENT,
something varchar(255) NOT NULL");
PREPARE createTableStmt FROM @createTable;
EXECUTE createTableStmt;
DEALLOCATE PREPARE createTableStmt;
Can someone please tell me how to do this in Postgres?