译者:魏 波
中国PG分会培训认证执行总监、资深数据库工程师,十多年的数据库运维管理及培训经验,掌握PostgreSQL架构部署、性能优化等,致力于推动PostgreSQL在中国的发展。
postgres=# SHOWdefault_transaction_read_only ;
default_transaction_read_only
-------------------------------
Off
(1 row)
postgres=# CREATE TABLE IF NOT EXISTS abc(id int); INSERT INTO abc VALUES (1) RETURNING id;
CREATE TABLE
id
----
1
(1 row)
INSERT 0 1复制
ALTER SYSTEM SET default_transaction_read_only TO on;
SELECT pg_reload_conf();
SHOW default_transaction_read_only;复制
确保default_transaction_read_only已启用:
postgres=# SHOW default_transaction_read_only;
default_transaction_read_only
-------------------------------
On
(1 row)复制
postgres=# INSERT INTO abc VALUES (2)RETURNING id;
ERROR: cannot execute INSERT in a read-only transaction复制
postgres=# SHOWdefault_transaction_read_only ;
default_transaction_read_on
-------------------------------
on
(1 row)
postgres=# SETdefault_transaction_read_only TO off;
SET
postgres=# INSERT INTO abc VALUES (2)RETURNING id;
Id
----
2
(1 row)
INSERT 0 1复制


新闻|Babelfish使PostgreSQL直接兼容SQL Server应用程序
中国PostgreSQL分会入选工信部重点领域人才能力评价机构
更多新闻资讯,行业动态,技术热点,请关注中国PostgreSQL分会官方网站
https://www.postgresqlchina.com
中国PostgreSQL分会生态产品
https://www.pgfans.cn
中国PostgreSQL分会资源下载站
https://www.postgreshub.cn
点赞、在看、分享、收藏
文章转载自开源软件联盟PostgreSQL分会,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
postgres=# SHOW transaction_read_only;
transaction_read_only
-----------------------
on
(1 row)
postgres=# set transaction_read_only to off;
ERROR: cannot set transaction read-write mode during recovery
遇到这种怎么解决呢?场景pg_rman恢复后启库不能创建对象
1年前

评论
相关阅读
外国CTO也感兴趣的开源数据库项目——openHalo
小满未满、
466次阅读
2025-04-21 16:58:09
9.9 分高危漏洞,尽快升级到 pgAdmin 4 v9.2 进行修复
严少安
356次阅读
2025-04-11 10:43:23
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
332次阅读
2025-04-15 14:48:05
openHalo问世,全球首款基于PostgreSQL兼容MySQL协议的国产开源数据库
严少安
306次阅读
2025-04-07 12:14:29
postgresql+patroni+etcd高可用安装
necessary
169次阅读
2025-03-28 10:11:23
转发有奖 | PostgreSQL 16 PGCM高级认证课程直播班招生中!
墨天轮小教习
149次阅读
2025-04-14 15:58:34
墨天轮PostgreSQL认证证书快递已发(2025年3月批)
墨天轮小教习
129次阅读
2025-04-03 11:43:25
SQL 优化之 OR 子句改写
xiongcc
93次阅读
2025-04-21 00:08:06
融合Redis缓存的PostgreSQL高可用架构
梧桐
88次阅读
2025-04-08 06:35:40
PostgreSQL拓展PGQ实现解析
chirpyli
86次阅读
2025-04-07 11:23:17