PG cannot execute UPDATE in a read-only transaction | How to add column if not exists on PostgreSQL
PG cannot execute UPDATE in a read-only transaction出现这种情况时,说明SQL语句可能是运行在一个PG集群中的非master节点上。查看data/pg_hba.conf。
SELECT pg_is_in_recovery();
This cannot return true in a master server because the only time a master server can be in recovery。
还有如下可能Normally the most plausible reasons for this kind of error are :
trying create statements on a read-only replica (the entire instance is read-only).
<username>
hasdefault_transaction_read_only
set to ONthe database has
default_transaction_read_only
set to ON
alter database exercises set default_transaction_read_only = off;
https://stackoverflow.com/questions/31186414/error-cannot-execute-create-table-in-a-read-only-transaction
How to add column if not exists on PostgreSQL
With Postgres 9.6 this can be done using the option if not exists
ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name INTEGER;
https://stackoverflow.com/questions/12597465/how-to-add-column-if-not-exists-on-postgresql
最新文章
- POJ 1066 Treasure Hunt【线段相交】
- HDU 2204 Eddy&#39;s爱好(容斥原理)
- python matplotlib 绘图
- Spring Boot 快速入门
- Calendar Game
- 1003: A Bug
- 查询Sqlserver数据库死锁的一个存储过程(转)
- Java学习日记-11 集合(1)
- c++实现dll注入其它进程
- Python学习笔记1(基础语法)
- (原)Matlab的svmtrain和svmclassify
- Centos升级gcc4.4.7升级gcc4.8手记
- 调用一个系统命令,并读取它的输出值(使用QProcess.readAll)
- LINUX 笔记-iostat命令
- 1.由浅入深解析 SimpleDateFormat
- JDK源码分析-String、StringBuilder、StringBuffer
- MEF 基础简介 四
- MyCat配置运行
- EF对应null的处理
- 为什么Java匿名内部类访问的外部局部变量或参数需要被final修饰