System information functions
RisingWave provides functions to help you get system information, including database, schema, user, role, session, and more.
`current_database()
Returns the name of the current database. You can use this function in SQL commands, functions, and operators.
current_role
Returns the name of the role that the current user is acting as, if the current user is a member of one or more roles.
current_shema
Returns the current schema. This is the schema that will be used for creating tables or other named objects without specifying a target schema.
current_user
Returns the name of the current effective user.
pg_get_keywords()
Returns a collection of records that provide information about the SQL keywords recognized by the server. Each record has three columns: word
, catcode
, and catdesc
.
The word
column contains the actual keyword, while the catcode
column indicates the category code of the keyword.
Here are the possible category codes and their meanings:
U
: Indicates an unreserved keyword.C
: Indicates a keyword that can be used as a column name.T
: Indicates a keyword that can be used as a type or function name.R
: Indicates a fully reserved keyword.
The catdesc
column contains a string that describes the category of the keyword. This description may be localized, depending on the language settings of the server.
pg_get_viewdef()
Returns the definition of a specified view or materialized view.
pg_index_column_has_property()
Checks if an index column has a specific property. The index
parameter represents the OID of the index, while the column
parameter represents the column number (starting from 1) within the index. If the property name is not recognized or doesn’t apply to the object, or if the OID or column number is invalid, this function will return NULL.
The supported properties are as follows:
asc
: Indicates whether the column sorts in ascending order on a forward scan.desc
: Indicates whether the column sorts in descending order on a forward scan.nulls_first
: Indicates whether the column sorts with nulls first on a forward scan.nulls_last
: Indicates whether the column sorts with nulls last on a forward scan.
pg_typeof()
Returns the standard name of the data type of the provided value. More specifically, it returns the OID of the data type of the provided value. It returns a regtype, which is an OID alias type. Therefore it’s the same as an OID for comparison purposes but displays as a type name.
pg_relation_size
Computes the disk space used by one “fork” of the specified relation.
Returns the size of the main data fork of the relation. This function can be used to determine if the main data fork of a relation exists. If its size is not 0, it means that the main data fork of the relation exists.
session_user
Returns the name of the current session user.
user
Returns the name of the current database user.
version()
Displays the PostgreSQL version and the RisingWave version implemented in the current instance of RisingWave.
Was this page helpful?