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> has default_transaction_read_only set to ON

  • the 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

 

PG cannot execute UPDATE in a read-only transaction | How to add column if not exists on PostgreSQL的更多相关文章

  1. Azkaban安装及分布式部署(multiple-executor)

    参考文章:https://blog.csdn.net/weixin_35852328/article/details/79327996 官网:https://azkaban.readthedocs.i ...

  2. 常用 PostgreSQL 脚本

    数据定义 数据库 -- 创建数据库 -- https://www.postgresql.org/docs/current/static/multibyte.html -- database_name, ...

  3. postgresql change table

    --if cloumn exist SELECT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='ent' A ...

  4. Mysql官方文档中争对安全添加列的处理方法。Mysql Add a Column to a table if not exists

    Add a Column to a table if not exists MySQL allows you to create a table if it does not exist, but d ...

  5. [转帖]postgres 创建新用户并授权-- 非常好的

    postgres 创建新用户并授权 https://blog.csdn.net/XuHang666/article/details/81506297 原作者总结的挺好的 可以用来学习一下. grant ...

  6. PostGIS管网连通性分析

    GIS在管网数据中的很重要的一个应用方向就是"管网空间分析",其中包括连通性分析.上下游分析.爆管分析等等.下面是我使用postgis来实现该"管网连通性分析" ...

  7. 【Spring】Spring的数据库开发 - 2、Spring JdbcTemplate的常用方法(execute、update、query)

    Spring JdbcTemplate的常用方法 文章目录 Spring JdbcTemplate的常用方法 execute() update() query() 简单记录-Java EE企业级应用开 ...

  8. pt-online-schema-change中update触发器的bug

    pt-online-schema-change在对表进行表结构变更时,会创建三个触发器. 如下文测试案例中的t2表,表结构如下: mysql> show create table t2\G . ...

  9. Delete,Update与LEFT Join

    UPDATE:UPDATE A SET ApproverID=NULL FROM [SH_MaterialApplyBuyBill] A LEFT JOIN [SH_MaterialApplyBuyB ...

随机推荐

  1. java 彻底理解 byte char short int float long double

    遇到过很多关于 数值类型范围的问题了,在这做一个总结,我们可以从多方面理解不同数值类型的所能表示的数值范围 在这里我们只谈论 java中的数值类型 首先说byte: 这段是摘自jdk中 Byte.ja ...

  2. C#获取IIS所有站点及虚拟目录和应用程序(包含名称及详细信息)

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  3. DevExpress Cpicturebox或者Dev控件 PictureEdit 按比例的缩放加载图片

    方法一:     如果要加载的图片的长宽比不是太过失衡, 1.可以改变picturebox的SizeMode属性为 PictureBoxSizeMode.StretchImage, 2.或者Dev控件 ...

  4. 【KiCad】 如何给元件给元件的管脚加上划线?

    如何给元件给元件的管脚加上划线? 在一线元件需要注明一些引脚是低电位使能的. 比如这样. 每款 EDA 软件有不同的做法,有的是在前后使用 /,有的是给每个字母加上 /. KiCad 不一样,使用的是 ...

  5. day9大纲

    01 作业内容回顾 函数的初识: 封装一个功能. def 函数名(): 函数体 函数的返回值:return 1,结束函数. 2,返回给执行者(函数名())值. return ----> None ...

  6. 用windbg 检查内存泄漏

    1.下载编译https://github.com/0cch/luadbg 2.编写脚本1.txt .load luadbg_v15*.sympath+ srv*c:\MyServerSymbols*h ...

  7. ORACLE 12C 之集群日志位置变化

    如果你还是使用 oracle 11g RAC 的目录结构方式寻找集群的日志,你会发现目录中所有的日志都是空的.actdb21:/oracle/app/12.2.0/grid/log/actdb21(+ ...

  8. 【转】Lambda表达式详解

    前言 1.天真热,程序员活着不易,星期天,也要顶着火辣辣的太阳,总结这些东西. 2.夸夸lambda吧:简化了匿名委托的使用,让你让代码更加简洁,优雅.据说它是微软自c#1.0后新增的最重要的功能之一 ...

  9. pyhanlp 中文词性标注与分词简介

    pyhanlp 中文词性标注与分词简介 pyhanlp实现的分词器有很多,同时pyhanlp获取hanlp中分词器也有两种方式 第一种是直接从封装好的hanlp类中获取,这种获取方式一共可以获取五种分 ...

  10. 源码查看工具ctags+vim

    一.ctags源码工具的安装 1.sudo apt-get install ctags 2.源码目录如下: 3.对配置文件进行配置 4.在末尾添加如下: 二.使用 1. 进入源码目录,输入ctags ...