系统信息函数。包括了会话信息函数,访问权限函数,schema可用性函数,系统catalog信息函数,对象信息和地址函数,注释信息函数,快照信息,提交事务信息,控制数据等。
Name | Return Type | Description |
current_catalog | name | 当前数据库 |
current_database() | name | 当前数据库 |
current_query() | text | 当前执行的查询的文本,如客户端提交的(可能包含多个语句) |
current_role | name | 当前用户 |
current_schema[()] | name | 当前的schema |
current_schemas(boolean) | name[] | 搜索路径中的模式名称,可选是否包括隐式模式 |
current_user | name | 当前执行的用户名 |
inet_client_addr() | inet | 连接IP(必须是通过网络连接) |
inet_client_port() | int | 网络连接端口 |
inet_server_addr() | inet | server IP |
inet_server_port() | int | server PG 端口 |
pg_backend_pid() | int | 附加到当前会话的服务器进程的进程ID |
pg_blocking_pids(int) | int[] | 阻止指定服务器进程ID获取锁的进程ID |
pg_conf_load_time() | timestamp with time zone | 配置文件加载时间 |
pg_current_logfile([text]) | text | 日志记录文件当前使用的主日志文件名或请求格式的日志 |
pg_my_temp_schema() | oid | 会话临时模式的OID,如果没有,则为0 |
pg_is_other_temp_schema(oid) | boolean | 模式是另一个会话的临时模式吗? |
pg_listening_channels() | setof text | 会话当前正在侦听的频道名称 |
pg_notification_queue_usage() | double | 当前占用的异步通知队列的分数(0-1) |
pg_postmaster_start_time() | timestamp with time zone | 服务器启动时间 |
pg_safe_snapshot_blocking_pids(int) | int[] | 阻止指定服务器进程ID获取安全快照的进程ID |
pg_trigger_depth() | int | PostgreSQL触发器的当前嵌套级别(如果不是从触发器内部直接或间接调用的话)0 |
session_user | name | 当前会话用户 |
user | name | 当前用户 |
version() | text | PG版本信息 |
Name | Return Type | Description |
has_any_column_privilege(user, table, privilege) | boolean | 用户是否具有任何列的权限 |
has_any_column_privilege(table, privilege) | boolean | 当前用户是否具有任何列的权限 |
has_column_privilege(user, table, column, privilege) | boolean | 用户是否具有列权限 |
has_column_privilege(table, column, privilege) | boolean | 当前用户是否具有列权限 |
has_database_privilege(user, database, privilege) | boolean | 用户是否拥有数据库权限 |
has_database_privilege(database, privilege) | boolean | 当前用户是否拥有数据库权限 |
has_foreign_data_wrapper_privilege(user, fdw, privilege) | boolean | 用户是否具有用于foreign data wrapper的特权 |
has_foreign_data_wrapper_privilege(fdw, privilege) | boolean | 当前用户是否具有用于foreign data wrapper的权限 |
has_function_privilege(user, function, privilege) | boolean | 用户对function是否具有权限 |
has_function_privilege(function, privilege) | boolean | 当前用户对function是否具有权限 |
has_language_privilege(user, language, privilege) | boolean | 用户是否对使用某个语言有权限 |
has_language_privilege(language, privilege) | boolean | 当前用户是否对使用某个语言有权限 |
has_schema_privilege(user, schema, privilege) | boolean | 用户是否对某个schema有权限 |
has_schema_privilege(schema, privilege) | boolean | 用户是否对某个schema有权限 |
has_sequence_privilege(user, sequence, privilege) | boolean | 用户是否对序列有权限 |
has_sequence_privilege(sequence, privilege) | boolean | 当前用户是否对序列有权限 |
has_server_privilege(user, server, privilege) | boolean | 用户是否有权限访问外部服务器 |
has_server_privilege(server, privilege) | boolean | 用户是否有权限访问外部服务器 |
has_table_privilege(user, table, privilege) | boolean | 用户是否具有表权限 |
has_table_privilege(table, privilege) | boolean | 当前用户是否具有表权限 |
has_tablespace_privilege(user, tablespace, privilege) | boolean | 用户是否具有表空间的权限 |
has_tablespace_privilege(tablespace, privilege) | boolean | 当前用户是否具有表空间的权限 |
has_type_privilege(user, type, privilege) | boolean | 用户是否具有类型权限 |
has_type_privilege(type, privilege) | boolean | 当前用户是否具有类型权限 |
pg_has_role(user, role, privilege) | boolean | 用户是否具有角色权限 |
pg_has_role(role, privilege) | boolean | 当前用户是否具有角色权限 |
row_security_active(table) | boolean | 当前用户是否具有用于表的行级安全激活 |
Name | Return Type | Description |
pg_collation_is_visible(collation_oid) | boolean | 在搜索路径中是否可见排序规则 |
pg_conversion_is_visible(conversion_oid) | boolean | 在搜索路径中是否可见转换 |
pg_function_is_visible(function_oid) | boolean | 函数在搜索路径中是否可见 |
pg_opclass_is_visible(opclass_oid) | boolean | 在搜索路径中是否可见操作符类 |
pg_operator_is_visible(operator_oid) | boolean | 在搜索路径中是否可见操作符 |
pg_opfamily_is_visible(opclass_oid) | boolean | 在搜索路径中是否可见操作符族 |
pg_statistics_obj_is_visible(stat_oid) | boolean | 统计对象在搜索路径中可见 |
pg_table_is_visible(table_oid) | boolean | 在搜索路径中是否可见表 |
pg_ts_config_is_visible(config_oid) | boolean | 在搜索路径中是否可见文本搜索配置 |
pg_ts_dict_is_visible(dict_oid) | boolean | 文本搜索词典在搜索路径中可见 |
pg_ts_parser_is_visible(parser_oid) | boolean | 在搜索路径中可见文本搜索解析器 |
pg_ts_template_is_visible(template_oid) | boolean | 在搜索路径中是否可见文本搜索模板 |
pg_type_is_visible(type_oid) | boolean | 在搜索路径中可见类型(或域) |
Name | Return Type | Description |
format_type(type_oid, typemod) | text | 获取数据类型的SQL名称 |
pg_get_constraintdef(constraint_oid) | text | 获取约束的定义 |
pg_get_constraintdef(constraint_oid,pretty_bool) | text | 获取约束的定义 |
pg_get_expr(pg_node_tree, relation_oid) | text | 对表达式的内部形式进行反编译,假设其中的任何VAR引用第二个参数所指示的关系。 |
pg_get_expr(pg_node_tree, relation_oid,pretty_bool) | text | 对表达式的内部形式进行反编译,假设其中的任何VAR引用第二个参数所指示的关系。 |
pg_get_functiondef(func_oid) | text | 获取函数的定义 |
pg_get_function_arguments(func_oid) | text | 获取函数定义的参数列表(带缺省值) |
pg_get_function_identity_arguments(func_oid) | text | 获取参数列表以标识函数(没有默认值) |
pg_get_function_result(func_oid) | text | 获取函数的返回子句 |
pg_get_indexdef(index_oid) | text | 获取索引的创建索引命令 |
pg_get_indexdef(index_oid, column_no,pretty_bool) | text | 为索引创建索引i命令,或者当column_no不是零时仅定义一个索引列 |
pg_get_keywords() | setof record | 获取SQL关键字及其类别 |
pg_get_ruledef(rule_oid) | text | 获取规则的规则 |
pg_get_ruledef(rule_oid, pretty_bool) | text | 获取规则的规则 |
pg_get_serial_sequence(table_name,column_name) | text | 获取序列或标识列使用的序列的名称。 |
pg_get_statisticsobjdef(statobj_oid) | text | 为扩展统计对象创建统计命令 |
pg_get_triggerdef(trigger_oid) | text | 获取创建[约束]触发器触发命令 |
pg_get_triggerdef(trigger_oid, pretty_bool) | text | 获取创建[约束]触发器触发命令 |
pg_get_userbyid(role_oid) | name | 用给定的类获得角色名 |
pg_get_viewdef(view_name) | text | 获取用于视图或物化视图的底层"select"命令 |
pg_get_viewdef(view_name, pretty_bool) | text | 获取用于视图或物化视图的底层"select"命令 |
pg_get_viewdef(view_oid) | text | 获取用于视图或物化视图的基础“select”命令 |
pg_get_viewdef(view_oid, pretty_bool) | text | 获取用于视图或物化视图的基础“选择”命令 |
pg_get_viewdef(view_oid, wrap_column_int) | text | 获取用于视图或物化视图的基础“选择”命令;带有字段的行被包装到指定的列数,漂亮的打印是隐含的。 |
pg_index_column_has_property(index_oid,column_no, prop_name) | boolean | 测试索引列是否具有指定属性 |
pg_index_has_property(index_oid, prop_name) | boolean | 测试索引是否具有指定属性 |
pg_indexam_has_property(am_oid, prop_name) | boolean | 测试索引访问方法是否具有指定属性 |
pg_options_to_table(reloptions) | setof record | 获取存储选项名称/值对的集合 |
pg_tablespace_databases(tablespace_oid) | setof oid | 获取具有表空间对象的数据库OID的集合 |
pg_tablespace_location(tablespace_oid) | text | 获取此表空间位于的文件系统中的路径。 |
pg_typeof(any) | regtype | 获取值的数据类型 |
collation for (any) | text | 获得论点的校对 |
to_regclass(rel_name) | regclass | 获取命名对象的OID |
to_regproc(func_name) | regproc | 获取命名函数的OID |
to_regprocedure(func_name) | regprocedure | 获取命名函数的OID |
to_regoper(operator_name) | regoper | 获取命名操作符的OID |
to_regoperator(operator_name) | regoperator | 获取命名操作符的OID |
to_regtype(type_name) | regtype | 获取命名类型的OID |
to_regnamespace(schema_name) | regnamespace | 获取命名模式的OID |
to_regrole(role_name) | regrole | 获取命名角色的OID |
Name | Return Type | Description |
pg_describe_object(catalog_id, object_id, object_sub_id) | text | 获取数据库对象的描述 |
pg_identify_object(catalog_id oid, object_id oid,object_sub_id integer) | type text, schema text, name text,identity text | 获取数据库对象的标识 |
pg_identify_object_as_address(catalog_id oid, object_idoid, object_sub_id integer) | type text, name text[], args text[] | 获取数据库对象地址的外部表示形式 |
pg_get_object_address(type text, name text[], args text[]) | catalog_id oid, object_id oid, object_sub_id int32 | 从数据库的外部表示获取数据库对象的地址 |
Name | Return Type | Description |
col_description(table_oid, column_number) | text | 获取表列的注释 |
obj_description(object_oid, catalog_name) | text | 获取数据库对象的注释 |
obj_description(object_oid) | text | 获取数据库对象的注释 |
shobj_description(object_oid, catalog_name) | text | 获取共享数据库对象的注释 |
Name | Return Type | Description |
txid_current() | bigint | 获取当前事务ID,如果当前事务没有一个,则分配新的事务ID。 |
txid_current_if_assigned() | bigint | 与txid_current()相同,但如果没有分配新的事务ID,则返回NULL而不是分配新的事务ID。 |
txid_current_snapshot() | txid_snapshot | 获取当前快照 |
txid_snapshot_xip(txid_snapshot) | setof bigint | 获取快照中的事务ID |
txid_snapshot_xmax(txid_snapshot) | bigint | 获取快照xmax |
txid_snapshot_xmin(txid_snapshot) | bigint | 获取快照xmin |
txid_visible_in_snapshot(bigint,txid_snapshot) | boolean | 事务ID在快照中可见吗?(不要与子事务ID一起使用) |
txid_status(bigint) | txid_status | 报告给定事务的状态:提交、中止、正在进行,如果事务ID太旧,则为NULL。 |
Name | Return Type | Description |
pg_xact_commit_timestamp(xid) | timestamp with time zone | 获取事务的提交时间戳 |
pg_last_committed_xact() | xid xid, timestamp timestamp with time zone | 获取最新提交事务的事务ID和提交时间戳 |
Name | Return Type | Description |
pg_control_checkpoint() | record | 返回有关当前检查点状态的信息。 |
pg_control_system() | record | 返回有关当前控制文件状态的信息。 |
pg_control_init() | record | 返回有关群集初始化状态的信息。 |
pg_control_recovery() | record | 返回有关恢复状态的信息。 |