背景

PostgreSQL大量的信息保存在元数据中,所有的元数据都是内部维护的,例如建表、建索引、删表等操作,自动维护元数据。

在某些迫不得已的情况下才可能需要直接对元数据进行修改。

默认情况下,用户是允许修改元数据的。

postgres=# \set VERBOSITY verbose  

postgres=# delete from pg_class where relname='test';
ERROR: 42809: permission denied: "pg_class" is a system catalog
LOCATION: setTargetTable, parse_clause.c:802

Greenplum 打开修改元数据开关的方法

postgres=# set allow_system_table_mods='DML';
SET
postgres=# begin;
BEGIN
postgres=# delete from pg_class where relname='test';
DELETE 1
postgres=# rollback;
ROLLBACK

PostgreSQL 打开修改元数据开关的方法

1、与Greenplum不同

postgres=# set allow_system_table_mods='DML';
ERROR: parameter "allow_system_table_mods" cannot be changed without restarting the server

2、需要重启生效,配置为on, off。

postgres=# alter system set allow_system_table_mods=on;
ALTER SYSTEM postgres=# \q
digoal@ -> pg_ctl stop -m fast
waiting for server to shut down....................... done
server stopped digoal@ -> pg_ctl start
waiting for server to start....2018-06-24 10:27:04.987 CST [4239] LOG: 00000: listening on IPv4 address "0.0.0.0", port 4000
2018-06-24 10:27:04.987 CST [4239] LOCATION: StreamServerPort, pqcomm.c:593
2018-06-24 10:27:04.990 CST [4239] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.4000"
2018-06-24 10:27:04.990 CST [4239] LOCATION: StreamServerPort, pqcomm.c:587
2018-06-24 10:27:04.991 CST [4239] LOG: 00000: listening on Unix socket "./.s.PGSQL.4000"
2018-06-24 10:27:04.991 CST [4239] LOCATION: StreamServerPort, pqcomm.c:587 ..2018-06-24 10:27:06.980 CST [4239] LOG: 00000: redirecting log output to logging collector process
2018-06-24 10:27:06.980 CST [4239] HINT: Future log output will appear in directory "log".
2018-06-24 10:27:06.980 CST [4239] LOCATION: SysLogger_Start, syslogger.c:635
done
server started digoal@ -> psql
psql (11beta1)
Type "help" for help. postgres=# show allow_system_table_mods;
allow_system_table_mods
-------------------------
on
(1 row) postgres=# begin;
BEGIN
postgres=# delete from pg_class where relname='test';
DELETE 1
postgres=# rollback;
ROLLBACK
postgres=# \d test
Table "public.test"
Column | Type | Collation | Nullable | Default
--------+--------+-----------+----------+-------------------------------------
id | bigint | | |
c1 | text | | | md5((random())::text)
c2 | text | | | md5((random())::text)
c3 | text | | | md5((random())::text)
c4 | text | | | md5((random())::text)
c5 | text | | | md5((random())::text)

参考

https://www.postgresql.org/docs/10/static/runtime-config-developer.html

转载自:https://yq.aliyun.com/articles/647438

Greenplum 与 PostgreSQL 修改元数据(catalog)的方法 allow_system_table_mods的更多相关文章

  1. [转帖]Greenplum: 基于PostgreSQL的分布式数据库内核揭秘(下篇)

    Greenplum: 基于PostgreSQL的分布式数据库内核揭秘(下篇) http://www.postgres.cn/v2/news/viewone/1/454 原作者:姚延栋 创作时间:201 ...

  2. linux修改主机名的方法

    linux修改主机名的方法 用hostname命令可以临时修改机器名,但机器重新启动之后就会恢复原来的值. #hostname   //查看机器名#hostname -i  //查看本机器名对应的ip ...

  3. 修改 SVN 账户密码的方法

    记是记不住 的,即便是每天都在用的东西,也有貌似熟悉其实很陌生的时候,或者说根本就是不熟悉.于是需要拿出来经常翻翻,比如我们的SVN账户配置,很简单的一个 case,你可能是svn使用高手,但不一定记 ...

  4. MyEclipse默认编码为GBK,修改为UTF8的方法

    MyEclipse 默认编码居然是GBK,js文件默认编码是ISO-....怎么可以这样呢? 都修改成UTF8的方法: 1.windows->Preferences...打开"首选项& ...

  5. Method Swizzle黑魔法,修改 ios 系统类库方法 SEL IMP

    Method Swizzle黑魔法,修改 ios 系统类库方法   版权声明:本文为博主原创文章,未经博主允许不得转载. 一般来说,系统提供的方法已经足够开发了,但是有的时候有些需求用普通方法不好做. ...

  6. Centos7.3下mysql5.7.18安装并修改初始密码的方法

    Centos7.3下mysql5.7.18安装并修改初始密码的方法 原文链接:http://www.jb51.net/article/116032.htm 作者:Javen205 字体:[增加 减小] ...

  7. SQLServer2008修改sa密码的方法与SQL server 2008数据库的备份与还原

    sa密码的修改转载自:http://blog.csdn.net/templar1000/article/details/20211191 SQL server 2008数据库的备份与还原转自 :htt ...

  8. Linux网络相关概念和修改IP地址的方法

    2.1.1  网卡的命名规则 CENTOS6的网卡命名方式:它会根据情况有所改变而非唯一且固定,在CENTOS6之前,网络接口使用连续号码命名: eth0. eth1等,当增加或删除网卡时,名称可能会 ...

  9. 修改MAC地址的方法 破解MAC地址绑定(抄)

    修改MAC地址的方法 破解MAC地址绑定   网卡的MAC地址是固化在网上EPROM中的物理地址,是一块网卡的“身份证”,通常为48位.在平常的应用中,有很多方面与MAC地址相关,如有些软件是和MAC ...

随机推荐

  1. day26——tyoe元类与object的联系、反射、函数与方法的区别、双下方法

    day26 type元类与object联系 type 获取对象从属于的类 python 中一切皆对象, 类在某种意义上也是一个对象,python中自己定义的类,以及大部分内置类,都是由type元类(构 ...

  2. bootstrap-wizard向导插件的使用

    引用文件 <link rel="stylesheet" href="bootstrap-wizard/bootstrap-wizard.css"> ...

  3. 删除elasticsearch 30天前的所有索引

    我的索引格式为 xxx-xxx-xxx-2019.06.27 xxx-xxxx-2019.06.27 脚本思路: 获取目前 es上所有索引,以日期进行拆分,然后用索引时间对比一个月前的日期,日期小于一 ...

  4. mybatis逆向生成dao mapper和example.java文件

    mabatis插件 <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>myba ...

  5. texlive2019安装

    TeX Live 是 TUG (TeX User Group) 发布并维护的的 TeX 系统,可以称得上是TeX的官方系统,官网为:https://www.tug.org/texlive/ 1.通过最 ...

  6. 函数式接口java.util.function

    什么是函数式接口 为什么要用函数式接口 java.util.function和其他的函数式接口 lamdba表达式 方法引用 流 Stream 1 什么是函数式接口 用@FunctionInterfa ...

  7. nginx.conf配置demo

    #user nobody; worker_processes 4; #error_log logs/error.log; #error_log logs/error.log notice; #erro ...

  8. 关于 Safari 浏览器不支持 location [ window.location.href window.open()] 跳转问题的解决方案

    最近在做项目时,碰到 safari 浏览器不支持location跳转问题,针对此问题,可以通过 js 模拟点击时间来解决,代码如下: <!DOCTYPE HTML> <html la ...

  9. CentOS - Eclipse安装Shelled

    一,下载Shelled: https://sourceforge.net/projects/shelled/ 二,打开Eclipse,以离线方式安装: Help->Install New Sof ...

  10. 使用SSH配置git服务器免密提交

    1. 生成SSH 1.1下载 下载工具 puttygen.exe ,当然其他工具请自行搜索. 下载地址: 下载地址1   百度网盘 (提取码: if8g)https://pan.baidu.com/s ...