PostgreSQL’s read only transaction mode

  • Post author:
  • Post category:其他



在只读模式下,PostgreSQL不允许如下SQL:



When a transaction is read-only, the following SQL commands are disallowed:


INSERT


,


UPDATE


,


DELETE


, and


COPY FROM


if the table they would write to is not a temporary table; all


CREATE


,


ALTER


, and


DROP


commands;


COMMENT


,


GRANT


,


REVOKE


,


TRUNCATE


; and


EXPLAIN ANALYZE


and


EXECUTE


if the command they would execute is among those listed. This is a high-level notion of read-only that does not prevent all writes to disk.




mydb=# begin;

BEGIN

mydb=#  set transaction read only;

SET


–插入数据失败

mydb=# insert into t values(generate_series(1,10000),’rudy’);

ERROR:  cannot execute INSERT in a read-only transaction



版权声明:本文为jumewo原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。