Website logo
⌘K
šŸ Homepage
šŸ‘‹Introduction
Key Concepts & Architecture
šŸš€Run Oxla in 2 minutes
šŸƒā€ā™‚ļøRun Oxla on S3
šŸ›«Multi-node Deployment
šŸ‘Øā€šŸ’»SQL Reference
SQL Queries
SQL Clauses
SQL Data Types
SQL Functions
Schema
Comment Support
ā›“ļøSQL Mutations
DELETE
UPDATE
🚨Error Handling
šŸ†šDifferences Between Oxla vs. PostgreSQL
šŸ”„Understanding Transactions
šŸ“ˆPublic Metrics
āš™ļøOxla Configuration File
✨Changelog
Docs powered byĀ Archbee
SQL Reference
...
SQL Functions
Other Functions

pg_get_expr

6min

Overview

The pg_get_expr function retrieves the internal form of an individual expression, such as the default value for a column.

Syntax

There are two versions of the pg_get_expr function:

Version 1

Pgsql
SELECT pg_get_expr('expr_text', relation_oid);


Version 2

Pgsql
SELECT pg_get_expr('expr_text', relation_oid, pretty_bool);


Please see the breakdown of both versions:

  • expr_text: The expression for which you want to obtain the internal representation. It can be any string value.
  • relation_oid: The OID (Object Identifier) of the table the expression belongs to. It is in integer type.
  • pretty_bool: A boolean value determining whether to format the expression in a more human-readable format (TRUE) or not (FALSE).

Output

Both versions of the pg_get_expr function return an empty string "".

Example

1. First, create a sample table named employees.

Pgsql
CREATE TABLE employees (
    id INT,
    name TEXT,
    salary TEXT
);


2. Get OID of the table.

Pgsql
SELECT oid FROM pg_class WHERE relname = 'employees';


You will get the OID of the table:

Pgsql
 oid  
------
 1018


3. Retrieve the internal form for the salary column using pg_get_expr.

Pgsql
-- Version 1
SELECT pg_get_expr('salary', 1018);

-- Version 2
SELECT pg_get_expr('salary', 1018, TRUE);


Both return the same value, an empty string "".

Pgsql
 pg_get_expr 
-------------
 




Updated 31 Oct 2023
Did this page help you?
PREVIOUS
has_schema_privilege
NEXT
pg_typeof
Docs powered byĀ Archbee
TABLE OF CONTENTS
Overview
Syntax
Output
Example
Docs powered byĀ Archbee

©2023 Oxla