随笔分类 - postgresql
随记
摘要:tds_fdw安装 编译安装 使用root用户执行 ``` tar -xzvf freetds-1.1.15.tar.gz cd freetds-1.1.15 source /home/postgres/.bash_profile ./configure --prefix=/usr/local --
阅读全文
摘要:1.切换到源码包的contrib路径下,ls 插件名称 `cd /data/soft/PostGreSQL/postgresql-10.20/contrib/pageinspect` 编译该插件 ``` make gcc -Wall -Wmissing-prototypes -Wpointer-ar
阅读全文
摘要:示例参数max_connections select * from pg_settings where name='max_connections'; -[ RECORD 1 ] + name | max_connections setting | 14 unit | category | Conn
阅读全文
摘要:锁类型 对应的数据库操作 ACCESS SHARE select ROW SHARE select for update, select for share ROW EXCLUSIVE update,delete,insert SHARE UPDATE EXCLUSIVE vacuum(withou
阅读全文
摘要:可以使用pg_probackup --help查看帮助 pg_probackup --help pg_probackup - utility to manage backup/recovery of PostgreSQL database. pg_probackup help [COMMAND] p
阅读全文
摘要:with的使用 可以看出来with相当于一个临时表,如下示例表明with语句ename_emp将emp的empno,ename两个字段作为一个临时表进行使用 mydb=# with ename_tmp as (select empno,ename from emp) mydb-# select *
阅读全文
摘要:交叉连接即即笛卡尔积 准备数据 CREATE TABLE EMP ( EMPNO int PRIMARY KEY, ENAME VARCHAR(10), JOB VARCHAR(9), MGR int, HIREDATE DATE, SAL int, COMM int, DEPTNO int ) i
阅读全文
摘要:测试环境为CentOS Linux release 7.9,oracle11g,pg10 1.安装oracle客户端 https://www.oracle.com/database/technologies/instant-client.html 根据系统选择对应版本 分别下载如下安装包 使用rpm
阅读全文
摘要:weather表的外键为cities的主键city字段,如下为表结构 mydb=# \d weather Table "public.weather" Column | Type | Collation | Nullable | Default + + + + city | character va
阅读全文
摘要:表分区 声明式划分 CREATE TABLE measurement ( city_id int not null,//城市id logdate date not null,//日期 peaktemp int,//峰值温度 unitsales int//销量 ); CREATE TABLE meas
阅读全文
摘要:pg中的schema类似于mysql数据库的角色 实例-->database-->schema-->数据库对象,表,视图,存储过程,函数等 CREATE SCHEMA myschema; 访问的时候需要写成schema_name.table_name的形式,比如 select * from sche
阅读全文
摘要:行级安全策略可以配置表中的那些数据可以被那些用户进行某种操作,比如rsl表中的name=aa的数据可以让a1看到 using 针对已经存在的记录的校验. 可实施在select, update, delete, ALL上 whth check 针对将要新增的记录的校验, 可实施在insert, upd
阅读全文
摘要:postgresql隐藏字段 在 PostgreSQL 中,当我们创建一个数据表时,数据库会隐式增加几个字段。这些字段由数据库系自动维护,用户一般不会感知 tableoid ctid xmin xmax cmin cmax oid tableoid 包含这一行的表的OID。该列是特别为从继承层次(见
阅读全文
摘要:我们在分组后,可以查出分组中复合条件的count,以及分组的count。 postgres=# create table test(id int, c1 int); CREATE TABLE postgres=# insert into test select generate_series(1,1
阅读全文
摘要:standard_conforming_strings=on,\失去了转义的意思,即‘’中是什么就是什么,但是standard_conforming_strings=off时,\会保留转义的含义所以select '\'即为'' 在Unicode转义语法中,反斜杠后的任何其他字符均按字面意义使用。因此
阅读全文
摘要:PostgreSQL Unicode标识符 mydb=# select U&"\0044\0061\0054\+000061" UESCAPE '\'; ERROR: column "DaTa" does not exist LINE 1: select U&"\0044\0061\0054\+00
阅读全文
摘要:postgresql内核日志格式为postgresql-2022-06-07_081953.log log_filename = 'PostgreSQL-%Y-%m-%d.log' PostgreSQL-%Y-%m-%d.log中的%Y%m%d格式如下解释 Linux日期格式 date +%Y%m%
阅读全文
摘要:修改参数 1.全局修改方法 alter system set 参数名='参数值' 2.非全局配置的参数修改方法 数据库级别的配置 alter database name set 参数名 to|= 参数值 //修改 alter database name reset configuration //重
阅读全文
摘要:数组类型 create table test_arr(id int,arr_people test[],arr_classid int[]); 增 insert into test_arr values(1,array['a','b','c','d','e'],array[1,2,3,4,5]);
阅读全文
摘要:创建测试用户,表空间,以及数据库,赋予权限 postgres=# create role pguser with encrypted password 'pguser'; CREATE ROLE postgres=# create tablespace tbs_mydb owner pguser l
阅读全文
浙公网安备 33010602011771号