当前位置:首页 > 编程笔记 > 正文
已解决

PostgreSQL 特殊数据类型UUID PG_LSN

来自网友在路上 163863提问 提问时间:2023-11-04 08:30:13阅读次数: 63

最佳答案 问答题库638位专家为你答疑解惑

1.UUID类型

UUID(Universally Unique Identifier)用于存储一个UUID。 UUID定义在RFC 4122和ISO/IEC 9834-8:2005中。它是一个128bit的数 字。

[postgres@postgres ~]$ 
[postgres@postgres ~]$ psql
psql (13.9)
Type "help" for help.postgres=# select uuid '1b34eaba-0d59-11e4-bf51-dc85de4d74f3' < uuid '1e0e95b0-0d59-11e4-bf51-dc85de4d74f3';?column? 
----------t
(1 row)postgres=# 

2.pg_lsn类型

pg_lsn类型是PostgreSQL9.4以上版本提供的一种表示LSN(Log Sequence Number)的数据类型。LSN表示WAL日志的位置。一些记录 WAL日志信息的系统表中某些字段的类型就是pg_lsn类型,

postgres=# \d pg_stat_replicationView "pg_catalog.pg_stat_replication"Column      |           Type           | Collation | Nullable | Default 
------------------+--------------------------+-----------+----------+---------pid              | integer                  |           |          | usesysid         | oid                      |           |          | usename          | name                     |           |          | application_name | text                     |           |          | client_addr      | inet                     |           |          | client_hostname  | text                     |           |          | client_port      | integer                  |           |          | backend_start    | timestamp with time zone |           |          | backend_xmin     | xid                      |           |          | state            | text                     |           |          | sent_lsn         | pg_lsn                   |           |          | write_lsn        | pg_lsn                   |           |          | flush_lsn        | pg_lsn                   |           |          | replay_lsn       | pg_lsn                   |           |          | write_lag        | interval                 |           |          | flush_lag        | interval                 |           |          | replay_lag       | interval                 |           |          | sync_priority    | integer                  |           |          | sync_state       | text                     |           |          | reply_time       | timestamp with time zone |           |          | postgres=# \d pg_replication_slotsView "pg_catalog.pg_replication_slots"Column        |  Type   | Collation | Nullable | Default 
---------------------+---------+-----------+----------+---------slot_name           | name    |           |          | plugin              | name    |           |          | slot_type           | text    |           |          | datoid              | oid     |           |          | database            | name    |           |          | temporary           | boolean |           |          | active              | boolean |           |          | active_pid          | integer |           |          | xmin                | xid     |           |          | catalog_xmin        | xid     |           |          | restart_lsn         | pg_lsn  |           |          | confirmed_flush_lsn | pg_lsn  |           |          | wal_status          | text    |           |          | safe_wal_size       | bigint  |           |          | postgres=#

在数据库内部,LSN是一个64bit的大整数,其输出类似如下格 式:

16/B374D848

pg_lsn类型可以使用基本的比较运算符,如“=”“>”“<”等, 两个pg_lsn的值可以相减,此时使用“-”运算符,相减所得的结果是 两个WAL日志相差的字节数

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"PostgreSQL 特殊数据类型UUID PG_LSN":http://eshow365.cn/6-31640-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!