Drop or create database from stored procedure in PostgreSQL
问题 I have a function that looks like this: BEGIN DROP DATABASE IF EXISTS db_1; END; I'm getting the following error: ERROR: DROP DATABASE cannot be executed from a function or multi-command string. Is it not possible to drop a database from a stored procedure in PostgreSQL? I'm using plpgsql. 回答1: The error message is just a s clear as the manual on this: DROP DATABASE cannot be executed inside a transaction block. A plgpsql function is surrounded by a transaction block automatically. The long