pg常用命令及笔记

1.pg配置连接,pg_hba.conf
host all all 223.254..7.111/32 md5

2.配置归档,postgres.conf
wal_level logical
archive_mode = on
archive_command = 'copy "%p" D:\\pg\\arch\\%f'

3.查询归档
select * from pg_setting where name like 'wal_level' OR name like 'archive%'


(测试案例表:
create table test_text(c1 int, c2 text);
insert into test_text values(1, '中国');
)

4.pg查询字符串的字节长度
select octet_length(t2) from test_text;

5. pg查询字符串的16进制字节编码
select encode(cast(t2 as bytea), 'hex'),encode(substr(cast(t2 as bytea), 1, 1), 'hex') from test_text;
--e4b8ad e59bbd

6.pg 常用视图
pg_catalog.pg_attribute --- 字段信息等
pg_catalog.pg_class --- 表等对象信息
pg_catalog.pg_namespace --- 模式名信息
pg_catalog.pg_type --- 数据类型信息

7.pg 字符集
select pg_client_encoding() --默认一般utf8

 

posted @ 2021-08-10 10:14  疾风泣影  阅读(715)  评论(0编辑  收藏  举报