华为云用户手册

  • STREAMING_REAPER_STATUS STREAMING_REAPER_STATUS系统表存储流引擎(由于规格变更,当前版本已经不再支持本特性,请不要使用)reaper线程的状态信息。 表1 STREAMING_REAPER_STATUS字段 名称 类型 描述 id integer CONTVIEW对象唯一的标识符,不可重复。 contquery_name name CONTVIEW对象的名称。 gather_interval text CONTVIEW对象设置的gather_interval参数值(自动聚合特定时间前历史数据的时间参数)。 gather_completion_time text CONTVIEW对象最近一次的GATHER(历史数据聚合)的完成时间。 父主题: 系统表
  • ChainedStreamBuilder的继承关系 ChainedStreamBuilder是逻辑复制的接口,实现类是ReplicationStreamBuilder,该类位于com.huawei.opengauss.jdbc.replication.fluent Package中,该类的声明如下: public class ReplicationStreamBuilder implements ChainedStreamBuilder
  • 获取发布包、依赖库和头文件 libpq依赖的库和头文件从发布包中获取,包名为 GaussDB -Kernel-数据库版本号-操作系统版本号-64bit-Libpq.tar.gz。其中include文件夹下的头文件为所需的头文件,lib文件夹中为所需的libpq库文件。使用libpq的程序必须包括头文件“libpq-fe.h”并且必须与libpq库连接。 除libpq-fe.h外,include文件夹下默认还存在头文件postgres_ext.h、gs_thread.h、gs_threadlocal.h,这三个头文件是libpq-fe.h的依赖文件。 父主题: 开发步骤
  • DB_TRIGGERS DB_TRIGGERS视图显示当前用户能访问到的触发器的信息。该视图同时存在于PG_CATA LOG 和SYS schema下。 表1 DB_TRIGGERS字段 名称 类型 描述 trigger_name character varying(64) 触发器名称。 table_owner character varying(64) 角色名称。 table_name character varying(64) 关系表名称。 status character varying(64) O:触发器在“origin”和“local”模式下触发。 D:触发器被禁用。 R:触发器在“replica”模式下触发。 A:触发器始终触发。 父主题: 系统视图
  • 用户权限设置 给用户直接授予某对象的权限,请使用GRANT。 将Schema中的表或者视图对象授权给其他用户或角色时,需要将表或视图所属Schema的USAGE权限同时授予该用户或角色。否则用户或角色将只能看到这些对象的名称,并不能实际进行对象访问。 例如,下面示例将Schema tpcds的权限赋给用户joe后,将表tpcds.web_returns的select权限赋给用户joe。 1 2 openGauss=# GRANT USAGE ON SCHEMA tpcds TO joe; openGauss=# GRANT SELECT ON TABLE tpcds.web_returns to joe; 给用户指定角色,使用户继承角色所拥有的对象权限。 创建角色。 新建一个角色lily,同时给角色指定系统权限CREATEDB: 1 openGauss=# CREATE ROLE lily WITH CREATEDB PASSWORD "********"; 给角色赋予对象权限,请使用GRANT。 例如,将模式tpcds的权限赋给角色lily后,将表tpcds.web_returns的select权限赋给角色lily。 1 2 openGauss=# GRANT USAGE ON SCHEMA tpcds TO lily; openGauss=# GRANT SELECT ON TABLE tpcds.web_returns to lily; 将角色的权限赋予用户。 1 openGauss=# GRANT lily to joe; 当将角色的权限赋予用户时,角色的属性并不会传递到用户。 回收用户权限,请使用REVOKE。 父主题: 用户及权限
  • 触发器函数 pg_get_triggerdef(oid) 描述:获取触发器的定义信息。 参数:待查触发器的OID。 返回值类型:text 示例: openGauss=# select pg_get_triggerdef(oid) from pg_trigger; pg_get_triggerdef -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CREATE TRIGGER tg1 BEFORE INSERT ON gtest26 FOR EACH STATEMENT EXECUTE PROCEDURE gtest_trigger_func() CREATE TRIGGER tg03 AFTER INSERT ON gtest26 FOR EACH ROW WHEN ((new.a IS NOT NULL)) EXECUTE PROCEDURE gtest_trigger_func() (2 rows) pg_get_triggerdef(oid, boolean) 描述:获取触发器的定义信息。 参数:待查触发器的OID及是否以pretty方式展示。 仅在创建trigger时指定WHEN条件的情况下,布尔类型参数才生效。 返回值类型:text 示例: openGauss=# select pg_get_triggerdef(oid,true) from pg_trigger; pg_get_triggerdef -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CREATE TRIGGER tg1 BEFORE INSERT ON gtest26 FOR EACH STATEMENT EXECUTE PROCEDURE gtest_trigger_func() CREATE TRIGGER tg03 AFTER INSERT ON gtest26 FOR EACH ROW WHEN (new.a IS NOT NULL) EXECUTE PROCEDURE gtest_trigger_func() (2 rows) openGauss=# select pg_get_triggerdef(oid,false) from pg_trigger; pg_get_triggerdef -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CREATE TRIGGER tg1 BEFORE INSERT ON gtest26 FOR EACH STATEMENT EXECUTE PROCEDURE gtest_trigger_func() CREATE TRIGGER tg03 AFTER INSERT ON gtest26 FOR EACH ROW WHEN ((new.a IS NOT NULL)) EXECUTE PROCEDURE gtest_trigger_func() (2 rows) 父主题: 函数和操作符
  • LOCAL_REL_IOSTAT 获取当前节点中数据文件I/O状态的累计值,显示为所有数据文件I/O状态的总和。 表1 LOCAL_REL_IOSTAT字段 名称 类型 描述 phyrds bigint 读物理文件的数目。 phywrts bigint 写物理文件的数目。 phyblkrd bigint 读物理文件的块的数目。 phyblkwrt bigint 写物理文件的块的数目。 父主题: File
  • CM报错信息 ER RMS G: "Fail to access the cluster static config file." SQLSTATE: c3000 CAUSE: "The cluster static config file is not generated or is manually deleted." ACTION: "Please check the cluster static config file." ERRMSG: "Fail to open the cluster static file." SQLSTATE: c3000 CAUSE: "The cluster static config file is not generated or is manually deleted." ACTION: "Please check the cluster static config file." ERRMSG: "Fail to read the cluster static file." SQLSTATE: c3001 CAUSE: "The cluster static file permission is insufficient." ACTION: "Please check the cluster static config file." ERRMSG: "Failed to read the static config file." SQLSTATE: c1000 CAUSE: "out of memeory." ACTION: "Please check the system memory and try again." ERRMSG: "Could not find the current node in the cluster by the node id %u." SQLSTATE: c3002 CAUSE: "The static config file probably contained content error." ACTION: "Please check static config file." ERRMSG: "Failed to open the logic config file." SQLSTATE: c3000 CAUSE: "The logic config file is not generated or is manually deleted." ACTION: "Please check the cluster static config file." ERRMSG: "Fail to read the logic static config file." SQLSTATE: c3001 CAUSE: "The logic static config file permission is insufficient." ACTION: "Please check the logic static config file." ERRMSG: "Failed to open or read the static config file." SQLSTATE: c1000 CAUSE: "out of memeory." ACTION: "Please check the system memory and try again." ERRMSG: "Failed to open the log file '%s'." SQLSTATE: c3000 CAUSE: "Log file not found." ACTION: "Please check the log file." ERRMSG: "Failed to open the log file '%s'." SQLSTATE: c3000 CAUSE: "The log file permission is insufficient." ACTION: "please check the log file." ERRMSG: "Failed to open the dynamic config file '%s'." SQLSTATE: c3000 CAUSE: "The dynamic config file permission is insufficient." ACTION: "Please check the dynamic config file." ERRMSG: "Failed to malloc memory, size = %lu." SQLSTATE: c1000 CAUSE: "out of memeory." ACTION: "Please check the system memory and try again." ERRMSG: "unrecognized AZ name '%s'." SQLSTATE: c3000 CAUSE: "The parameter(%s) entered by the user is incorrect." ACTION: "Please check the parameter entered by the user and try again." ERRMSG: "unrecognized minorityAz name '%s'." SQLSTATE: c3000 CAUSE: "The parameter(%s) entered by the user is incorrect." ACTION: "Please check the parameter entered by the user and try again." ERRMSG: "Get GAUSSHOME failed." SQLSTATE: c3000 CAUSE: "The environment variable('GAUSSHOME') is incorrectly configured." ACTION: "Please check the environment variable('GAUSSHOME')." ERRMSG: "Get current user name failed." SQLSTATE: c3000 CAUSE: "N/A" ACTION: "Please check the environment." ERRMSG: "-B option must be specified." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-T option must be specified.\n" SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "can't stop one node or instance with -m normal." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "can't stop one node or instance with -m resume." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "can't stop one availability zone with -m resume." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "log level or cm server arbitration mode must be specified." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "log level or cm server arbitration mode need not be specified." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-R is needed." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-D is needed." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-n and -R are needed." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-n and -D are needed." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "no operation specified." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "no cm directory specified." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "Please check the usage of switchover." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-n and -z cannot be specified at the same time." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-m cannot be specified at the same time with -n or -z." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-n node(%d) is invalid." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-n node is needed." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "%s: -C is needed." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-z value must be 'ALL' when query mppdb cluster." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-v is needed." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-C is needed." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-Cv is needed." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-L value must be 'ALL' when query logic cluster." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "unrecognized LC name '%s'." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-n is needed." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "There is no '%s' information in cluster." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-D path is too long.\n" SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-D path is invalid." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-n node(%s) is invalid." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-R only support when the cluster is single-inst." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-t time is invalid." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "-votenum is invalid." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "unrecognized build mode." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "unrecognized build mode '%s'." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "too many command-line arguments (first is '%s')." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "unrecognized operation mode '%s'." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "no cm directory specified." SQLSTATE: c3000 CAUSE: "%s: The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "Failed to malloc memory." SQLSTATE: c1000 CAUSE: "out of memeory." ACTION: "Please check the system memory and try again." ERRMSG: "Failed to open etcd: %s." SQLSTATE: c4000 CAUSE: "Etcd is abnormal." ACTION: "Please check the Cluster Status and try again." ERRMSG: "[PATCH-ERROR] hotpatch command or path set error." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "no standby datanode in single node cluster." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "restart logic cluster failed." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "restart logic cluster failed" SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." ERRMSG: "The option parameter is not specified." SQLSTATE: c3000 CAUSE: "The cmdline entered by the user is incorrect." ACTION: "Please check the cmdline entered by the user(%s)." 父主题: 错误日志信息参考
  • _PG_FOREIGN_SERVERS 显示外部服务器的信息。该视图只有sysadmin权限可以查看。 表1 _PG_FOREIGN_SERVERS字段 名称 类型 描述 oid oid 外部服务器的OID。 srvoptions text[] 外部服务器指定选项,使用“keyword=value”格式的字符串。 foreign_server_catalog information_schema.sql_identifier 外部服务器所在database名称(永远为当前数据库)。 foreign_server_name information_schema.sql_identifier 外部服务器名称。 foreign_data_wrapper_catalog information_schema.sql_identifier 外部数据封装器所在database名称(永远为当前数据库)。 foreign_data_wrapper_name information_schema.sql_identifier 外部数据封装器名称。 foreign_server_type information_schema.character_data 外部服务器的类型。 foreign_server_version information_schema.character_data 外部服务器的版本。 authorization_identifier information_schema.sql_identifier 外部服务器的所有者的角色名称。 父主题: Information Schema
  • GLOBAL_STAT_USER_INDEXES 得到各节点数据库中用户自定义普通表的索引状态信息。 表1 GLOBAL_STAT_USER_INDEXES字段 名称 类型 描述 node_name name 节点名称。 relid oid 这个索引的表的OID。 indexrelid oid 索引的OID。 schemaname name 索引的模式名。 relname name 索引的表名。 indexrelname name 索引名。 idx_scan bigint 索引上开始的索引扫描数。 idx_tup_read bigint 通过索引上扫描返回的索引项数。 idx_tup_fetch bigint 通过使用索引的简单索引扫描抓取的活表行数。 父主题: Object
  • 废弃函数 GaussDB中下列函数在最新版本中已废弃: gs_wlm_get_session_info gs_wlm_get_user_session_info pgxc_get_csn pgxc_get_stat_dirty_tables pgxc_get_thread_wait_status pgxc_gtm_snapshot_status pgxc_is_committed pgxc_lock_for_backup pgxc_lock_for_sp_database pgxc_lock_for_transfer pgxc_log_comm_status pgxc_max_datanode_size pgxc_node_str pgxc_pool_check pgxc_pool_connection_status pgxc_pool_reload pgxc_prepared_xact pgxc_snapshot_status pgxc_stat_dirty_tables pgxc_unlock_for_sp_database pgxc_unlock_for_transfer pgxc_version array_extend prepare_statement_status remote_rto_stat dbe_perf.global_slow_query_info dbe_perf.global_slow_query_info_bytime dbe_perf.global_slow_query_history pg_stat_get_pooler_status pg_stat_get_wlm_node_resource_info pg_stat_get_wlm_session_info_internal DBE_PERF.get_wlm_controlgroup_ng_config() DBE_PERF.get_wlm_user_resource_runtime() global_space_shrink pg_pool_validate gs_stat_ustore table_skewness(text) table_skewness(text, text, text) gs_wlm_get_session_info() gs_wlm_get_user_session_info() - - 父主题: 函数和操作符
  • ADM_SYNONYMS ADM_SYNONYMS视图显示数据库中所有同义词的信息。需要有系统管理员权限才可以访问。该视图同时存在于PG_CATALOG和SYS Schema下。 表1 ADM_SYNONYMS字段 名称 类型 描述 owner text 同义词的所有者。 schema_name text 同义词所属模式名。 synonym_name text 同义词的名称。 table_owner text 关联对象的所有者。尽管该列称为table_owner,但它拥有的该关联对象不一定是表,可以是任何数据库通用对象,例如视图、存储过程、同义词等。 table_name text 关联对象名。尽管该列称为table_name,但此关联对象不一定是表,可以是任何数据库通用对象,例如视图、存储过程、同义词等。 table_schema_name text 关联对象所属模式名。尽管该列称为table_schema_name,但此schema下的该关联对象不一定是表,可以是任何数据库通用对象,例如视图、存储过程、同义词等。 父主题: 系统视图
  • 使用分区表 分区表是把逻辑上的一张表根据某种方案分成几张物理块进行存储。这张逻辑上的表称之为分区表,物理块称之为分区。分区表是一张逻辑表,不存储数据,数据实际是存储在分区上的。分区表和普通表相比具有以下优点: 改善查询性能:对分区对象的查询可以仅搜索自己关心的分区,提高检索效率。 增强可用性:如果分区表的某个分区出现故障,表在其他分区的数据仍然可用。 方便维护:如果分区表的某个分区出现故障,需要修复数据,只修复该分区即可。 GaussDB数据库 支持的分区表为一级分区表和二级分区表,其中一级分区表包括范围分区表、间隔分区表、列表分区表、哈希分区表四种,二级分区表包括范围分区、列表分区、哈希分区两两组合的九种。 范围分区表:将数据基于范围映射到每一个分区,这个范围是由创建分区表时指定的分区键决定的。这种分区方式是最为常用的,并且分区键经常采用日期,例如将销售数据按照月份进行分区。 间隔分区表:是一种特殊的范围分区表,相比范围分区表,新增间隔值定义,当插入记录找不到匹配的分区时,可以根据间隔值自动创建分区。 列表分区表:将数据中包含的键值分别存储在不同的分区中,依次将数据映射到每一个分区,分区中包含的键值由创建分区表时指定。 哈希分区表:将数据根据内部哈希算法依次映射到每一个分区中,包含的分区个数由创建分区表时指定。 二级分区表:由范围分区、列表分区、哈希分区任意组合得到的分区表,其一级分区和二级分区均可以使用前面三种定义方式。 父主题: 表设计最佳实践
  • PG_TRIGGER PG_TRIGGER系统表存储触发器信息。 表1 PG_TRIGGER字段 名称 类型 描述 oid oid 行标识符(隐含属性,必须明确选择)。 tgrelid oid 触发器所在表的OID。 tgname name 触发器名。 tgfoid oid 要被触发器调用的函数。 tgtype smallint 触发器类型。 tgenabled "char" O:触发器在“origin”和“local”模式下触发。 D:触发器被禁用。 R:触发器在“replica”模式下触发。 A:触发器始终触发。 tgisinternal boolean 内部触发器标识,如果为true表示内部触发器。 tgconstrrelid oid 完整性约束引用的表。 tgconstrindid oid 完整性约束的索引。 tgconstraint oid 约束触发器在PG_CONSTRAINT中的OID。 tgdeferrable boolean 约束触发器是为DEFERRABLE类型。 tginitdeferred boolean 约束触发器是否为INITIALLY DEFERRED类型。 tgnargs smallint 触发器函数入参个数。 tgattr int2vector 当触发器指定列时的列号,未指定则为空数组。 tgargs bytea 传递给触发器的参数。 tgqual pg_node_tree 表示触发器的WHEN条件,如果没有则为null。 tgowner oid 触发器的所有者。 父主题: 系统表
  • PG_TABLES PG_TABLES视图可用来查询数据库中每个表的有用信息。 表1 PG_TABLES字段 名称 类型 引用 描述 schemaname name PG_NAMESPACE.nspname 表的模式名。 tablename name PG_CLASS.relname 表名。 tableowner name pg_get_userbyid(PG_CLASS.relowner) 表的所有者。 tablespace name PG_TABLESPACE.spcname 包含表的表空间,默认为NULL。 hasindexes boolean PG_CLASS.relhasindex 如果表上有索引(或者最近拥有)则为TRUE,否则为FALSE。 hasrules boolean PG_CLASS.relhasruls 如果表上有规则,则为TRUE,否则为FALSE。 hastriggers boolean PG_CLASS.RELHASTRIGGERS 如果表上有触发器,则为TRUE,否则为FALSE。 tablecreator name pg_get_userbyid(PG_OBJECT.creator) 表的创建者。 created timestamp with time zone PG_OBJECT.ctime 表的创建时间。 last_ddl_time timestamp with time zone PG_OBJECT.mtime 最后一次对该表执行DDL操作的时间。 父主题: 系统视图
  • 参数 表1 SQLBindCol参数 关键字 参数说明 StatementHandle 语句句柄。 ColumnNumber 要绑定结果集的列号。起始列号为0,以递增的顺序计算列号,第0列是书签列。若未设置书签页,则起始列号为1。 TargetType 缓冲区中C数据类型的标识符。 TargetValuePtr 输出参数:指向与列绑定的数据缓冲区的指针。SQLFetch函数返回这个缓冲区中的数据。如果此参数为一个空指针,则StrLen_or_IndPtr是一个有效值。 BufferLength TargetValuePtr指向缓冲区的长度,以字节为单位。 StrLen_or_IndPtr 输出参数:缓冲区的长度或指示器指针。若为空值,则未使用任何长度或指示器值。
  • 原型 1 2 3 4 5 6 SQLRETURN SQLBindCol(SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType, SQLPOINTER TargetValuePtr, SQLLEN BufferLength, SQLLEN *StrLen_or_IndPtr);
  • 参数说明 WITH [ RECURSIVE ] with_query [, ...] 用于声明一个或多个可以在主查询中通过名称引用的子查询,相当于临时表。 如果声明了RECURSIVE,那么允许SELECT子查询通过名称引用它自己。 其中with_query的详细格式为: with_query_name [ ( column_name [, ...] ) ] AS [ [ NOT ] MATERIALIZED ] ( {SELECT | VALUES | INSERT | UPDATE | DELETE} ) – with_query_name指定子查询生成的结果集名称,在查询中可使用该名称访问子查询的结果集。 – column_name指定子查询结果集中显示的列名。 – 每个子查询可以是SELECT,VALUES,INSERT,UPDATE或DELETE语句。 – 用户可以使用MATERIALIZED / NOT MATERIALIZED对CTE进行修饰。 如果声明为MATERIALIZED,WITH查询将被物化,生成一个子查询结果集的拷贝,在引用处直接查询该拷贝,因此WITH子查询无法和主干SELECT语句进行联合优化(如谓词下推、等价类传递等),对于此类场景可以使用NOT MATERIALIZED进行修饰,如果WITH查询语义上可以作为子查询内联执行,则可以进行上述优化。 如果用户没有显式声明物化属性则遵守以下规则:如果CTE只在所属主干语句中被引用一次,且语义上支持内联执行,则会被改写为子查询内联执行,否则以CTE Scan的方式物化执行。 INSERT ON DUPLICATE KEY UPDATE不支持WITH及WITH RECURSIVE子句。 plan_hint子句 以/*+ */的形式在INSERT关键字后,用于对INSERT对应的语句块生成的计划进行hint调优,详细用法请参见章节使用Plan Hint进行调优。每条语句中只有第一个/*+ plan_hint */注释块会作为hint生效,里面可以写多条hint。 table_name 要插入数据的目标表名。 取值范围:已存在的表名。 partition_clause 指定分区插入操作 PARTITION { ( partition_name ) | FOR ( partition_value [, ...] ) } | SUBPARTITION { ( subpartition_name ) | FOR ( subpartition_value [, ...] ) } 关键字详见SELECT一节介绍 如果value子句的值和指定分区不一致,会抛出异常。 示例详见CREATE TABLE SUBPARTITION column_name 目标表中的字段名: 字段名可以使用子字段名或者数组下标修饰。 没有在字段列表中出现的每个字段,将由系统默认值,或者声明时的默认值填充,若都没有则用NULL填充。例如,向一个复合类型中的某些字段插入数据的话,其他字段将是NULL。 目标字段(column_name)可以按顺序排列。如果没有列出任何字段,则默认全部字段,且顺序为表声明时的顺序。 如果VALUE子句和QUERY中只提供了N个字段,则目标字段为前N个字段。 VALUE子句和QUERY提供的值在表中从左到右关联到对应列。 取值范围:已存在的字段名。 expression 赋予对应column的一个有效表达式或值: 如果是INSERT ON DUPLICATE KEY UPDATE语句下,expression可以为VALUES(column_name)或EXCLUDED.column_name用来表示引用冲突行对应的column_name字段的值。需注意,其中VALUES(column_name)不支持嵌套在表达式中(例如VALUES(column_name)+1),但EXCLUDED不受此限制。 向表中字段插入单引号 " ' "时需要使用单引号自身进行转义。 如果插入行的表达式不是正确的数据类型,系统试图进行类型转换,若转换不成功,则插入数据失败,系统返回错误信息。 DEFAULT 对应字段名的缺省值。如果没有缺省值,则为NULL。 query 一个查询语句(SELECT语句),将查询结果作为插入的数据。 RETURNING 返回实际插入的行,RETURNING列表的语法与SELECT的输出列表一致。注意:INSERT ON DUPLICATE KEY UPDATE不支持RETURNING子句。 output_expression INSERT命令在每一行都被插入之后用于计算输出结果的表达式。 取值范围:该表达式可以使用table的任意字段。可以使用*返回被插入行的所有字段。 output_name 字段的输出名称。 取值范围:字符串,符合标识符命名规范。 ON DUPLICATE KEY UPDATE 对于带有唯一约束(UNIQUE INDEX或PRIMARY KEY)的表,如果插入数据违反唯一约束,则对冲突行执行UPDATE子句完成更新,对于不带唯一约束的表,则仅执行插入。UPDATE时,若指定NOTHING则忽略此条插入,可通过"EXCLUDE." 或者 "VALUES()" 来选择源数据相应的列。 支持触发器,触发器执行顺序由实际执行流程决定: 执行INSERT: 触发BEFORE INSERT、 AFTER INSERT触发器。 执行UPDATE:触发BEFORE INSERT、BEFORE UPDATE、AFTER UPDATE触发器。 执行UPDATE NOTHING: 触发BEFORE INSERT触发器。 不支持延迟生效(DEFERRABLE)的唯一约束或主键。 如果表中存在多个唯一约束,如果所插入数据违反多个唯一约束,对于检测到冲突的第一行进行更新,其他冲突行不更新(检查顺序与索引维护具有强相关性,一般先创建的索引先进行冲突检查)。 如果插入多行,这些行均与表中同一行数据存在唯一约束冲突,则按照顺序,第一条执行插入或更新,之后依次执行更新。 主键、唯一索引列不允许UPDATE。 不支持内存表。 expression支持使用子查询表达式,其语法与功能同UPDATE。子查询表达式中支持使用“EXCLUDED.”来选择源数据相应的列。
  • 注意事项 只有拥有表INSERT权限的用户,才可以向表中插入数据。用户被授予INSERT ANY TABLE权限,相当于用户对除系统模式之外的任何模式具有USAGE权限,并且拥有这些模式下表的INSERT权限。 如果使用RETURNING子句,用户必须要有该表的SELECT权限。 如果使用ON DUPLICATE KEY UPDATE,用户必须要有该表的INSERT、UPDATE权限,UPDATE子句中列的SELECT权限。 如果使用QUERY子句插入来自查询里的数据行,用户还需要拥有在查询里使用的表的SELECT权限。 生成列不能被直接写入。在INSERT命令中不能为生成列指定值,但是可以指定关键字DEFAULT。 当连接到TD兼容的数据库时,td_compatible_truncation参数设置为on时,将启用超长字符串自动截断功能,在后续的INSERT语句中(不包含外表的场景下),对目标表中char和varchar类型的列上插入超长字符串时,系统会自动按照目标表中相应列定义的最大长度对超长字符串进行截断。 如果向字符集为字节类型编码(SQL_ASCII,LATIN1等)的数据库中插入多字节字符数据(如汉字等),且字符数据跨越截断位置,这种情况下,按照字节长度自动截断,自动截断后会在尾部产生非预期结果。如果用户有对于截断结果正确性的要求,建议用户采用UTF8等能够按照字符截断的输入字符集作为数据库的编码集。
  • 语法格式 [ WITH [ RECURSIVE ] with_query [, ...] ] INSERT [/*+ plan_hint */] INTO table_name [partition_clause] [ AS alias ] [ ( column_name [, ...] ) ] { DEFAULT VALUES | VALUES {( { expression | DEFAULT } [, ...] ) }[, ...] | query } [ ON DUPLICATE KEY UPDATE { NOTHING | { column_name = { expression | DEFAULT } } [, ...] [ WHERE condition ] }] [ RETURNING {* | {output_expression [ [ AS ] output_name ] }[, ...]} ];
  • GLOBAL_CONFIG_SETTINGS GLOBAL_CONFIG_SETTINGS显示各节点数据库运行时参数的相关信息。 表1 GLOBAL_CONFIG_SETTINGS的字段 名称 类型 描述 node_name text 节点名称。 name text 参数名称。 setting text 参数当前值。 unit text 参数的隐式结构。 category text 参数的逻辑组。 short_desc text 参数的简单描述。 extra_desc text 参数的详细描述。 context text 设置参数值的上下文,包括internal,postmaster,sighup,backend,superuser,user。 vartype text 参数类型,包括bool,enum,integer,real,string。 source text 参数的赋值方式。 min_val text 参数最小值。如果参数类型不是数值型,那么该字段值为null。 max_val text 参数最大值。如果参数类型不是数值型,那么该字段值为null。 enumvals text[] enum类型参数合法值。如果参数类型不是enum型,那么该字段值为null。 boot_val text 数据库启动时参数默认值。 reset_val text 数据库重置时参数默认值。 sourcefile text 设置参数值的配置文件。如果参数不是通过配置文件赋值,那么该字段值为null。 sourceline integer 设置参数值的配置文件的行号。如果参数不是通过配置文件赋值,那么该字段值为null。 父主题: Configuration
  • PG_GTT_ATTACHED_PIDS PG_GTT_ATTACHED_PIDS视图可用来查看哪些会话正在使用全局临时表,调用pg_gtt_attached_pid()函数。 表1 PG_GTT_ATTACHED_PIDS字段 名称 类型 描述 schemaname name schema名称。 tablename name 全局临时表名称。 relid oid 全局临时表的oid。 pids bigint[] 线程pid列表。 sessionids bigint[] 会话id列表。 父主题: 系统视图
  • PG_DESCRIPTION PG_DESCRIPTION系统表可以给每个数据库对象存储一个可选的描述(注释)。许多内置的系统对象的描述提供了PG_DESCRIPTION的初始内容。 这个表的功能类似PG_SHDESCRIPTION,用于记录整个数据库范围内共享对象的注释。 表1 PG_DESCRIPTION字段 名称 类型 引用 描述 objoid oid 任意OID属性 这条描述所描述的对象的OID。 classoid oid PG_CLASS.oid 这个对象出现的系统表的OID。 objsubid integer - 对于一个表字段的注释,它是字段号(objoid和classoid指向表自身)。对于其它对象类型,它是零。 description text - 对该对象描述的任意文本。 父主题: 系统表
  • 语法 创建函数时需要指定返回值SETOF datatype。 return_next_clause::= return_query_clause::= 对以上语法的解释如下: 当需要函数返回一个集合时,使用RETURN NEXT或者RETURN QUERY向结果集追加结果,然后继续执行函数的下一条语句。随着后续的RETURN NEXT或RETURN QUERY命令的执行,结果集中会有多个结果。函数执行完成后会一起返回所有结果。 RETURN NEXT可用于标量和复合数据类型。 RETURN QUERY有一种变体RETURN QUERY EXECUTE,后面还可以增加动态查询,通过USING向查询插入参数。
  • 示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 openGauss=# CREATE TABLE t1(a int); openGauss=# INSERT INTO t1 VALUES(1),(10); --RETURN NEXT openGauss=# CREATE OR REPLACE FUNCTION fun_for_return_next() RETURNS SETOF t1 AS $$ DECLARE r t1%ROWTYPE; BEGIN FOR r IN select * from t1 LOOP RETURN NEXT r; END LOOP; RETURN; END; $$ LANGUAGE plpgsql; openGauss=# call fun_for_return_next(); a --- 1 10 (2 rows) -- RETURN QUERY openGauss=# CREATE OR REPLACE FUNCTION fun_for_return_query() RETURNS SETOF t1 AS $$ DECLARE r t1%ROWTYPE; BEGIN RETURN QUERY select * from t1; END; $$ language plpgsql; openGauss=# call fun_for_return_query(); a --- 1 10 (2 rows)
  • 语法格式 创建增量物化视图 CREATE INCREMENTAL MATERIALIZED VIEW [ view_name ] AS { query_block }; 全量刷新物化视图 REFRESH MATERIALIZED VIEW [ view_name ]; 增量刷新物化视图 REFRESH INCREMENTAL MATERIALIZED VIEW [ view_name ]; 删除物化视图 DROP MATERIALIZED VIEW [ view_name ]; 查询物化视图 SELECT * FROM [ view_name ];
  • 示例 --准备数据。 openGauss=# CREATE TABLE t1(c1 int, c2 int); openGauss=# INSERT INTO t1 VALUES(1, 1); openGauss=# INSERT INTO t1 VALUES(2, 2); --创建增量物化视图。 openGauss=# CREATE INCREMENTAL MATERIALIZED VIEW mv AS SELECT * FROM t1; CREATE MATERIALIZED VIEW --插入数据。 openGauss=# INSERT INTO t1 VALUES(3, 3); INSERT 0 1 --增量刷新物化视图。 openGauss=# REFRESH INCREMENTAL MATERIALIZED VIEW mv; REFRESH MATERIALIZED VIEW --查询物化视图结果。 openGauss=# SELECT * FROM mv; c1 | c2 ----+---- 1 | 1 2 | 2 3 | 3 (3 rows) --插入数据。 openGauss=# INSERT INTO t1 VALUES(4, 4); INSERT 0 1 --全量刷新物化视图。 openGauss=# REFRESH MATERIALIZED VIEW mv; REFRESH MATERIALIZED VIEW --查询物化视图结果。 openGauss=# select * from mv; c1 | c2 ----+---- 1 | 1 2 | 2 3 | 3 4 | 4 (4 rows) --删除物化视图。 openGauss=# DROP MATERIALIZED VIEW mv; DROP MATERIALIZED VIEW
  • GS_STAT_SESSION_CU GS_STAT_SESSION_CU视图查询整个数据库各个节点中,当前运行session的CU命中情况。session退出后,相应的统计数据会清零。数据库重启后,统计数据也会清零。 表1 GS_STAT_SESSION_CU字段 名称 类型 描述 mem_hit integer 内存命中次数。 hdd_sync_read integer 硬盘同步读次数。 hdd_asyn_read integer 硬盘异步读次数。 父主题: 系统视图
  • DB_TAB_COMMENTS DB_TAB_COMMENTS视图显示当前用户可访问的所有表和视图的注释信息。该视图同时存在于PG_CATALOG和SYS Schema下。 表1 DB_TAB_COMMENTS字段 名称 类型 描述 owner character varying(64) 表或视图的所有者。 table_name character varying(64) 表或视图的名称。 comments text 注释。 父主题: 系统视图
  • STATEMENT_HISTORY 获得当前节点的执行语句的信息。查询视图必须具有sysadmin权限或者monitor admin权限。只可在系统库中查询到结果,用户库中无法查询。 表1 STATEMENT_HISTORY字段 名称 类型 描述 dbname name 数据库名称。 schemaname name schema名称。 origin_node integer 节点名称。 user_name name 用户名。 application_name text 用户发起的请求的应用程序名称。 client_addr text 用户发起的请求的客户端地址。 client_port integer 用户发起的请求的客户端端口。 unique_query_id bigint 归一化SQL ID。 debug_query_id bigint 唯一SQL ID。 query text 归一化SQL。 start_time timestamp with time zone 语句启动的时间。 finish_time timestamp with time zone 语句结束的时间。 slow_sql_threshold bigint 语句执行时慢SQL的标准。 transaction_id bigint 事务ID。 thread_id bigint 执行线程ID。 session_id bigint 用户session id。 n_soft_parse bigint 软解析次数,n_soft_parse + n_hard_parse可能大于n_calls,因为子查询未计入n_calls。 n_hard_parse bigint 硬解析次数,n_soft_parse + n_hard_parse可能大于n_calls,因为子查询未计入n_calls。 query_plan text 语句执行计划。 n_returned_rows bigint SELECT返回的结果集行数。 n_tuples_fetched bigint 随机扫描行。 n_tuples_returned bigint 顺序扫描行。 n_tuples_inserted bigint 插入行。 n_tuples_updated bigint 更新行。 n_tuples_deleted bigint 删除行。 n_blocks_fetched bigint buffer的块访问次数。 n_blocks_hit bigint buffer的块命中次数。 db_time bigint 有效的DB时间花费,多线程将累加(单位:微秒)。 cpu_time bigint CPU消耗时间(单位:微秒)。 execution_time bigint 执行器内执行时间(单位:微秒)。 parse_time bigint SQL解析时间(单位:微秒)。 plan_time bigint SQL生成计划时间(单位:微秒)。 rewrite_time bigint SQL重写时间(单位:微秒)。 pl_execution_time bigint plpgsql上的执行时间(单位:微秒)。 pl_compilation_time bigint plpgsql上的编译时间(单位:微秒)。 data_io_time bigint I/O上的时间花费(单位:微秒)。 net_send_info text 通过物理连接发送消息的网络状态,包含时间(微秒)、调用次数、吞吐量(字节)。单机模式下不支持该字段。 net_recv_info text 通过物理连接接收消息的网络状态,包含时间(微秒)、调用次数、吞吐量(字节)。单机模式下不支持该字段。 net_stream_send_info text 通过逻辑连接发送消息的网络状态,包含时间(微秒)、调用次数、吞吐量(字节)。单机模式下不支持该字段。 net_stream_recv_info text 通过逻辑连接接收消息的网络状态,包含时间(微秒)、调用次数、吞吐量(字节)。单机模式下不支持该字段。 lock_count bigint 加锁次数。 lock_time bigint 加锁耗时。 lock_wait_count bigint 加锁等待次数。 lock_wait_time bigint 加锁等待耗时。 lock_max_count bigint 最大持锁数量。 lwlock_count bigint 轻量级加锁次数(预留)。 lwlock_wait_count bigint 轻量级等锁次数。 lwlock_time bigint 轻量级加锁时间(预留)。 lwlock_wait_time bigint 轻量级加锁时间。 details bytea 语句锁事件的列表,该列表按时间顺序记录事件,记录的数量受参数track_stmt_details_size的影响。 事件包括: 加锁开始 加锁结束 等锁开始 等锁结束 放锁开始 放锁结束 轻量级等锁开始 轻量级等锁结束 is_slow_sql boolean 该SQL是否为slow SQL。 trace_id text 驱动传入的trace id,与应用的一次请求相关联。 advise text 可能导致该SQL为slow SQL的风险信息(可能同时存在多种风险)。 Cast Function Cause Index Miss. :表示存在隐式转换导致索引匹配失败的风险。 Limit too much rows. :表示存在limit值过大导致SQL变慢的风险。 Proleakproof of function is false. :表示函数的proleakproof值为false,此时函数在生成计划时因存在数据泄露的风险而不会使用统计信息,影响生成计划的准确性,从而存在SQL变慢的风险。 父主题: Query
共100000条
提示

您即将访问非华为云网站,请注意账号财产安全