更新时间:2021-12-19 21:40:17
除嵌入式SQL外,PostgreSQL没有禁用自动提交的设置.如果您尝试关闭自动提交功能(例如PSQL),则会看到类似此错误的信息.
PostgreSQL doesn't have a setting that disables autocommit except for embedded SQL. If you try to set autocommit off in, say, PSQL, you'll see something like this error.
sandbox=# set autocommit=off;
ERROR: SET AUTOCOMMIT TO OFF is no longer supported
相反,请使用BEGIN启动事务.在PostgreSQL中,您可以启动事务并在单个语句中设置隔离级别. (其他平台需要多个语句.)骨架语法(适用于PostgreSQL 9.2)是
Instead, use BEGIN to start a transaction. In PostgreSQL, you can start a transaction and set the isolation level in a single statement. (Other platforms require multiple statements.) Skeleton syntax for PostgreSQL 9.2 is
BEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]
where transaction_mode is one of:
ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ |
READ COMMITTED | READ UNCOMMITTED }
READ WRITE | READ ONLY
[ NOT ] DEFERRABLE
使用COMMIT或ROLLBACK结束事务.
End the transaction with either COMMIT or ROLLBACK.