Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Session Information Functions

Updated on 2024-09-03 GMT+08:00

current_catalog

Description: Name of the current database (called "catalog" in the SQL standard), same as current_database().

Return type: name

Example:

1
2
3
4
5
SELECT current_catalog;
 current_database
------------------
 gaussdb
(1 row)

current_database()

Description: Name of the current database

Return type: name

Example:

1
2
3
4
5
SELECT current_database();
 current_database
------------------
 gaussdb
(1 row)

current_query()

Description: Text of the currently executing query, as submitted by the client (might contain more than one statement)

Return type: text

Example:

1
2
3
4
5
SELECT current_query();
      current_query
-------------------------
 SELECT current_query();
(1 row)

current_schema[()]

Description: Name of current schema current_schema returns the first valid schema name in the search path. (If the search path is empty or contains no valid schema name, NULL is returned.) This is the schema that will be used for any tables or other named objects that are created without specifying a target schema.

Return type: name

Example:

1
2
3
4
5
SELECT current_schema();
 current_schema
----------------
 public
(1 row)

current_schemas(boolean)

Description: current_schemas(boolean) returns an array of the names of all schemas presently in the search path. The Boolean option determines whether implicitly included system schemas such as pg_catalog are included in the returned search path.

Return type: name[]

Example:

1
2
3
4
5
SELECT current_schemas(true);
   current_schemas
---------------------
 {pg_catalog,public}
(1 row)
NOTE:

The search path can be altered at run time. The command is:

1
SET search_path TO schema [, schema, ...]

current_user

Description: User name of current execution context current_user is the user identifier that is applicable for permission checking. Normally it is equal to the session user, but it can be changed by using SET ROLE. It also changes during the execution of functions with the attribute SECURITY DEFINER.

Return type: name

Example:

1
2
3
4
5
SELECT current_user;
 current_user
--------------
 dbadmin
(1 row)

inet_client_addr()

Description: Displays the IP address of the currently connected client.

NOTE:
  • This function is available only in remote connection mode.
  • If the database is connected to the local PC, the value is empty.

Return type: inet

Example:

1
2
3
4
5
SELECT inet_client_addr();
 inet_client_addr
------------------
 10.10.0.50
(1 row)

inet_client_port()

Description: Displays the port number of the currently connected client.

NOTE:

This function is available only in remote connection mode.

Return type: integer

Example:

1
2
3
4
5
SELECT inet_client_port();
 inet_client_port
------------------
            33143
(1 row)

inet_server_addr()

Description: Displays the IP address of the current server.

NOTE:
  • This function is available only in remote connection mode.
  • If the database is connected to the local PC, the value is empty.

Return type: inet

Example:

1
2
3
4
5
SELECT inet_server_addr();
 inet_server_addr
------------------
 10.10.0.13
(1 row)

inet_server_port()

Description: Displays the port of the current server. All these functions return NULL if the current connection is via a Unix-domain socket.

NOTE:

This function is available only in remote connection mode.

Return type: integer

Example:

1
2
3
4
5
SELECT inet_server_port();
 inet_server_port
------------------
 8000
(1 row)

pg_backend_pid()

Description: Process ID of the server process attached to the current session

Return type: integer

Example:

1
2
3
4
5
SELECT pg_backend_pid();
 pg_backend_pid
-----------------
 140229352617744
(1 row)

pg_conf_load_time()

Description: Configures load time. pg_conf_load_time returns the timestamp with time zone when the server configuration files were last loaded.

Return type: timestamp with time zone

Example:

1
2
3
4
5
SELECT pg_conf_load_time();
      pg_conf_load_time       
------------------------------
 2017-09-01 16:05:23.89868+08
(1 row)

pg_my_temp_schema()

Description: pg_my_temp_schema returns the OID of the current session's temporary schema, or zero if it has none (because it has not created any temporary tables). pg_is_other_temp_schema returns true if the given OID is the OID of another session's temporary schema.

Return type: OID

Example:

1
2
3
4
5
SELECT pg_my_temp_schema();
 pg_my_temp_schema 
-------------------
                 0
(1 row)

pg_is_other_temp_schema(oid)

Description: Whether the schema is the temporary schema of another session.

Return type: boolean

Example:

1
2
3
4
5
SELECT pg_is_other_temp_schema(25356);
 pg_is_other_temp_schema
-------------------------
 f
(1 row)

pg_postmaster_start_time()

Description: Server start time pg_postmaster_start_time returns the timestamp with time zone when the server started.

Return type: timestamp with time zone

Example:

1
2
3
4
5
SELECT pg_postmaster_start_time();
   pg_postmaster_start_time   
------------------------------
 2017-08-30 16:02:54.99854+08
(1 row)

pg_trigger_depth()

Description: Current nesting level of triggers

Return type: integer

Example:

1
2
3
4
5
SELECT pg_trigger_depth();
 pg_trigger_depth 
------------------
                0
(1 row)

pgxc_version()

Description: Postgres-XC version information

Return type: text

Example:

1
2
3
4
5
SELECT pgxc_version();
                                                pgxc_version                                                 
-------------------------------------------------------------------------------------------------------------
 Postgres-XC 1.1 on x86_64-unknown-linux-gnu, based on PostgreSQL 9.2.4, compiled by g++ (GCC) 5.4.0, 64-bit
(1 row)

session_user

Description: Queries the session username. session_user is usually the user who initiated the current database connection, but administrators can change this setting with SET SESSION AUTHORIZATION.

Return type: name

Example:

1
2
3
4
5
SELECT session_user;
 session_user
--------------
 dbadmin
(1 row)

user

Description: Is equivalent to current_user.

Return type: name

Example:

1
2
3
4
5
SELECT user;
 current_user
--------------
 dbadmin
(1 row)

version()

Description: version information. version returns a string describing a server's version.

Return type: text

Example:

1
2
3
4
5
SELECT version();
                                                                version                                                                
---------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.2.4 gsql ((GaussDB 8.1.3 build 39137c2d) compiled at 2022-04-01 15:43:11 commit 3629 last mr 5138 release) on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 5.4.0, 64-bit
(1 row)

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback