当前位置:网站首页>Gbase 8C - SQL reference 6 SQL syntax (13)
Gbase 8C - SQL reference 6 SQL syntax (13)
2022-07-27 07:08:00 【aisirea】
Function description
Generate a notification .
Grammar format
NOTIFY channel [ , payload ]
Parameter description
- channel: Name of the channel to signal , Can be any identifier ;
- payload: To communicate through notification “ load ” character string , It must be a simple string , By default , The string cannot exceed 8000 byte .
matters needing attention
NOTIFY The queue is used to keep the notification information that has been sent but has not been monitored , If the queue is full ( Default 8GB), call NOTIFY The transaction will be submitted with errors .
It has been implemented NOTIFY The transaction of cannot be prepared for two-phase commit .
You can also use functions pg_notify(text, text) Sending notice , The first parameter of this function is the channel name , The second parameter is the load .
Example
LISTEN virtual;
LISTEN
NOTIFY virtual;
NOTIFY
Asynchronous notification "virtual" received from server process with PID 2302.
NOTIFY virtual, 'This is the payload';
NOTIFY
Asynchronous notification "virtual" with payload "This is the payload" received from server process with PID 2302.
LISTEN foo;
LISTEN
SELECT pg_notify('fo' || 'o', 'pay' || 'load');
pg_notify
-----------
(1 row)
Asynchronous notification "foo" with payload "payload" received from server process with PID 2302.
Grammar compatible
stay SQL There is no in the standard NOTIFY sentence .
Related to the grammar
Function description
Pause the database cluster .
Grammar format
PAUSE CLUSTER
matters needing attention
The pause command will organize any new things to start and wait for the existing things to complete before returning . The existing session is still connected to CN node , Just new things will not be implemented .
Pause command is used for database maintenance 、 restart DN Node and manual failover . In the suspended state, the application will not receive an error , Unless the connection times out .
When the pause ends, you can execute UNPAUSE CLUSTER command .
Example
PAUSE CLUSTER;
PAUSE CLUSTER
Grammar compatible
stay SQL There is no in the standard PAUSE CLUSTER sentence .
Function description
Create a preliminary statement .
Grammar format
PREPARE name [ ( data_type [, ...] ) ] AS statement
Parameter description
- name: Specify the name of the prepared statement , It must be unique in this session ;
- data_type: Data type of parameter ;
- statement: yes SELECT INSERT、UPDATE、DELETE or VALUES One of the statements .
matters needing attention
To check PostgreSQL Query plan for a prepared statement , have access to EXPLAIN, for example EXPLAIN EXECUTE.
By querying pg_prepared_statements System view to see all available prepared statements in the session .
Example
PREPARE insert_customer(int,varchar(200),date,varchar(50)) AS INSERT INTO customer VALUES($1,$2,$3,$4);
PREPARE
EXECUTE insert_customer(11, ' d ','20200618',15974236);
INSERT 0 1
Grammar compatible
SQL The standard includes a PREPARE sentence , But it is only used for embedded SQL.
Related to the grammar
Function description
Prepare for the two-phase commit of the current transaction .
Grammar format
PREPARE TRANSACTION transaction_id
Parameter description
- transaction_id: Identifier of the transaction to be committed , Used later in COMMIT PREPARED or ROLLBACK PREPARED When identifying this transaction . The identifier must be less than 200 Byte string , And it cannot have the same name as any identifier that has been used by the current preparatory transaction .
matters needing attention
The transaction function is automatically maintained by the database , Transaction functions should not be used explicitly .
This command must be used in transactions .
All currently available ready transactions are listed in pg_prepared_xacts In the system view .
Grammar compatible
PREPARE TRANSACTION It's a kind of PostgreSQL Expand .
Related to the grammar
COMMIT PREPARED, ROLLBACK PREPARED
Function description
Modify the owner of the database object .
REASSIGN OWNED The system is required to integrate all old_roles The owner of the owned database object is changed to new_role.
Grammar format
REASSIGN OWNED BY { old_role | CURRENT_USER | SESSION_USER } [, ...]
TO { new_role | CURRENT_USER | SESSION_USER }
Parameter description
- old_role: The role name of the old owner ;
- new_role: The name of the new role that will become the owner of these objects .
matters needing attention
REASSIGN OWNED It is often used to prepare before deleting roles .
perform REASSIGN OWNED You need permissions on the original role and the target role .
Grammar compatible
REASSIGN OWNED Command is a kind of PostgreSQL Expand .
Related to the grammar
DROP OWNED, DROP ROLE, ALTER DATABASE
Function description
Replace the contents of a materialized view .
Grammar format
REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] name
[ WITH [ NO ] DATA ]
Parameter description
- CONCURRENTLY: Refreshing the materialized view does not block the concurrent selection on the materialized view ;
- name: The name of the materialized view to refresh , Can be modified by patterns .
matters needing attention
nothing
Example
REFRESH MATERIALIZED VIEW mv_customer;
REFRESH MATERIALIZED VIEW
Grammar compatible
REFRESH MATERIALIZED VIEW It's a kind of PostgreSQL Expand .
Related to the grammar
CREATE MATERIALIZED VIEW, ALTER MATERIALIZED VIEW, DROP MATERIALIZED VIEW
Function description
Rebuild index .
Grammar format
REINDEX [ ( VERBOSE ) ] { INDEX | TABLE | SCHEMA | DATABASE | SYSTEM } name
Parameter description
- INDEX: Rebuild the specified index ;
- TABLE: Rebuild all indexes of the specified table , If the table has dependent "TOAST" surface , The table will also be indexed ;
- SCHEMA: Rebuild all indexes of the specified schema , If the table of the mode has dependent "TOAST" surface , Then the table will also be re indexed , Indexes on shared directories will also be processed , In this case REINDEX Cannot execute within a transaction ;
- DATABASE: Rebuild all indexes in the current database , In this case REINDEX Cannot execute within a transaction ;
- SYSTEM: Rebuild indexes on all system tables on the current database , The index on the user table will not be processed , In this case REINDEX Cannot execute within a transaction ;
- name: The index that needs to be rebuilt 、 surface 、 Database name , Tables and indexes can be decorated with patterns ;
- VERBOSE: Print a progress report when each index is rebuilt .
matters needing attention
You need to use REINDEX Rebuild index :
- Index crash , And no longer contain valid data .
- The index becomes “ Overstaffed ”, Contains a large number of empty pages or near empty pages .
- Storage parameters changed for index ( For example, fill factor ), And I hope this change will take full effect .
- Use CONCURRENTLY Option failed to create index , Left a “ illegal ” Indexes .
Example
REINDEX INDEX customer_idx;
REINDEX
Grammar compatible
stay SQL There is no in the standard REINDEX command .
Function description
Restore the specified runtime parameters to the default values .
Grammar format
RESET configuration_parameter
RESET ALL
Parameter description
- configuration_parameter: Name of the runtime parameter , have access to SHOW ALL Command to view runtime parameters ;
- ALL: All runtime parameters .
matters needing attention
RESET Transactional behavior and SET identical : Its impact will be reversed by transaction rollback .
Example
RESET timezone;
RESET
Grammar compatible
ESET It's a kind of PostgreSQL Expand .
Related to the grammar
Function description
Used to revoke the permissions of one or more roles .
Grammar format
REVOKE [ GRANT OPTION FOR ]
{ { SELECT | INSERT | UPDATE | DELETE | TRUNCATE | REFERENCES | TRIGGER }
[, ...] | ALL [ PRIVILEGES ] }
ON { [ TABLE ] table_name [, ...]
| ALL TABLES IN SCHEMA schema_name [, ...] }
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ { SELECT | INSERT | UPDATE | REFERENCES } ( column_name [, ...] )
[, ...] | ALL [ PRIVILEGES ] ( column_name [, ...] ) }
ON [ TABLE ] table_name [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ { USAGE | SELECT | UPDATE }
[, ...] | ALL [ PRIVILEGES ] }
ON { SEQUENCE sequence_name [, ...]
| ALL SEQUENCES IN SCHEMA schema_name [, ...] }
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ { CREATE | CONNECT | TEMPORARY | TEMP } [, ...] | ALL [ PRIVILEGES ] }
ON DATABASE database_name [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ USAGE | ALL [ PRIVILEGES ] }
ON DOMAIN domain_name [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ USAGE | ALL [ PRIVILEGES ] }
ON FOREIGN DATA WRAPPER fdw_name [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ USAGE | ALL [ PRIVILEGES ] }
ON FOREIGN SERVER server_name [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ EXECUTE | ALL [ PRIVILEGES ] }
ON { FUNCTION function_name [ ( [ [ argmode ] [ arg_name ] arg_type [, ...] ] ) ] [, ...]
| ALL FUNCTIONS IN SCHEMA schema_name [, ...] }
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ USAGE | ALL [ PRIVILEGES ] }
ON LANGUAGE lang_name [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ { SELECT | UPDATE } [, ...] | ALL [ PRIVILEGES ] }
ON LARGE OBJECT loid [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ { CREATE | USAGE } [, ...] | ALL [ PRIVILEGES ] }
ON SCHEMA schema_name [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ CREATE | ALL [ PRIVILEGES ] }
ON TABLESPACE tablespace_name [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ USAGE | ALL [ PRIVILEGES ] }
ON TYPE type_name [, ...]
FROM { [ GROUP ] role_name | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ ADMIN OPTION FOR ]
role_name [, ...] FROM role_name [, ...]
[ CASCADE | RESTRICT ]
Parameter description
Permission category and parameter description , Please see the GRANT.
matters needing attention
keyword PUBLIC Represents an implicitly defined group with all roles .
The privileges that any particular role has include those directly granted to that role 、 Permissions obtained from the role that this role is a member of and granted to PUBLIC Authority . therefore , from PUBLIC Take back SELECT Privileges don't necessarily mean that all characters will lose on the object SELECT Privilege , Those roles that are granted directly or through another role will still have it . Similarly , Withdraw from a user SELECT after , If PUBLIC There is still a SELECT jurisdiction , This user can still use SELECT.
Appoint GRANT OPTION FOR when , Only revoke the authority authorized for this authority , Without revoking the permission itself .
Such as user A Have a table UPDATE jurisdiction , And WITH GRANT OPTION Options , meanwhile A Give this permission to the user B, Then the user B The permissions held are called dependent permissions . When the user A When the permission or authorization option held is revoked , Dependent permissions still exist , But if it's stated CASCADE, Then all dependent permissions are revoked .
A user can only revoke the permissions directly granted by itself . for example , If the user A Be designated to authorize (WITHADMIN OPTION) Options , And give a permission to the user B, And then the user B It also gives users C, Then the user A Can't directly C Revocation of authority . however , user A Users can be revoked B Authorization options , And use CASCADE. such , user C Your permission will be automatically revoked . Another example : If A and B It's all given to C Same permissions , be A Can revoke his own authorization options , But it cannot be revoked B Of , therefore C Still have this permission .
If you execute REVOKE The permissions held by the role of are obtained through multi-level membership , It is uncertain which included role executes the command . On this occasion , The best way is to use SET ROLE Become a specific role , And then execute REVOKE, Otherwise, permissions that you don't want to delete may be deleted , Or there is no permission to delete .
Example
REVOKE INSERT ON g_c1 FROM PUBLIC;
REVOKE
Grammar compatible
This command is partially compatible SQL.
Related to the grammar
Function description
Rollback the current transaction and cancel all updates in the current transaction .
Grammar format
ROLLBACK [ WORK | TRANSACTION ]
Parameter description
- WORK | TRANSACTION: Optional keywords , In addition to increasing readability , There's no other effect .
matters needing attention
If not issued within a transaction ROLLBACK There will be no problem , But a warning message will be thrown .
Example
BEGIN;
BEGIN
ROLLBACK;
ROLLBACK
Grammar compatible
SQL The standard only specifies ROLLBACK and ROLLBACK WORK Two forms . besides , This command is completely up to standard .
Related to the grammar
边栏推荐
- newest! SASAC releases new measures for digital transformation of state-owned enterprises
- Future, futuretask and completable future are often asked in interviews
- DataScience:数据生成之在原始数据上添加小量噪声(可自定义噪声)进而实现构造新数据(dataframe格式数据存储案例)
- EasyCVR平台播放设备录像时,拖动时间轴播放无效是什么原因?
- Account management and authority
- 基于SSM学生成绩管理系统
- Vscode connection remote server development
- Express framework
- Cyclegan parsing
- 仿真模型简单介绍
猜你喜欢

Qi Yue: thiol modified oligodna | DNA modified cdte/cds core-shell quantum dots | DNA coupled indium arsenide InAs quantum dots InAs DNA QDs

网易云信亮相 GIAC 全球互联网架构大会,解密新一代音视频架构在元宇宙场景的实践...

Leetcode series (I): buying and selling stocks

Netease Yunxin appeared at the giac global Internet architecture conference to decrypt the practice of the new generation of audio and video architecture in the meta universe scene

DNA (deoxyribonucleic acid) supply | carbon nanotube nucleic acid loaded dna/rna material | dna/rna nucleic acid modified magnetic nanoparticles

nvidia-smi 各参数意义

Shell programming specifications and variables

Li Hongyi 2020 deep learning and human language processing dlhlp conditional generation by RNN and attention-p22

Customer cases | focus on process experience to help bank enterprise app iteration

DNA research experiment application | cyclodextrin modified nucleic acid cd-rna/dna | cyclodextrin nucleic acid probe / quantum dot nucleic acid probe
随机推荐
Image super-resolution evaluation index
R2live code learning record (3): radar feature extraction
Using docker to install and deploy redis on CentOS
Sok: the faults in our asrs: an overview of attacks against automatic speech recognition
EasyCVR平台播放设备录像时,拖动时间轴播放无效是什么原因?
DNA modified zinc oxide | DNA modified gold nanoparticles | DNA coupled modified carbon nanomaterials
CASS11.0.0.4 for AutoCAD2010-2023免狗使用方法
How to learn C language? This article gives you the complete answer
Fix the problem that the paging data is not displayed when searching the easycvr device management list page
Peptide nucleic acid oligomer containing azobenzene monomer (nh2-tnt4, n-pnas) Qiyue biological customization
What is the reason why dragging the timeline is invalid when playing device videos on the easycvr platform?
IoTDB 的C# 客户端发布 0.13.0.7
Day012 一维数组的应用
仿真模型简单介绍
Reasoning speed of model
Introduction to the official functions of easyrecovery14 data recovery software
Boostrap
R2LIVE代码学习记录(3):对雷达特征提取
What is the reason why the channel list is empty on the intelligent security video platform easycvr?
大疆livox定制的格式CustomMsg格式转换pointcloud2