pg_cast

存储数据类型转换路径的系统表

pg_cast 是一个 系统目录 表,存储数据类型转换路径,包括内置和用户定义的路径。

pg_cast 添加于 PostgreSQL 7.3

psql

\dC 提供可用转换的列表。

按PostgreSQL版本定义

pg_cast (PostgreSQL 17)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default 
-------------+--------+-----------+----------+---------
 oid         | oid    |           | not null | 
 castsource  | oid    |           | not null | 
 casttarget  | oid    |           | not null | 
 castfunc    | oid    |           | not null | 
 castcontext | "char" |           | not null | 
 castmethod  | "char" |           | not null | 
Indexes:
    "pg_cast_oid_index" PRIMARY KEY, btree (oid)
    "pg_cast_source_target_index" UNIQUE CONSTRAINT, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 16)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default 
-------------+--------+-----------+----------+---------
 oid         | oid    |           | not null | 
 castsource  | oid    |           | not null | 
 casttarget  | oid    |           | not null | 
 castfunc    | oid    |           | not null | 
 castcontext | "char" |           | not null | 
 castmethod  | "char" |           | not null | 
Indexes:
    "pg_cast_oid_index" PRIMARY KEY, btree (oid)
    "pg_cast_source_target_index" UNIQUE CONSTRAINT, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 15)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default 
-------------+--------+-----------+----------+---------
 oid         | oid    |           | not null | 
 castsource  | oid    |           | not null | 
 casttarget  | oid    |           | not null | 
 castfunc    | oid    |           | not null | 
 castcontext | "char" |           | not null | 
 castmethod  | "char" |           | not null | 
Indexes:
    "pg_cast_oid_index" PRIMARY KEY, btree (oid)
    "pg_cast_source_target_index" UNIQUE CONSTRAINT, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 14)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default 
-------------+--------+-----------+----------+---------
 oid         | oid    |           | not null | 
 castsource  | oid    |           | not null | 
 casttarget  | oid    |           | not null | 
 castfunc    | oid    |           | not null | 
 castcontext | "char" |           | not null | 
 castmethod  | "char" |           | not null | 
Indexes:
    "pg_cast_oid_index" PRIMARY KEY, btree (oid)
    "pg_cast_source_target_index" UNIQUE CONSTRAINT, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 13)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default 
-------------+--------+-----------+----------+---------
 oid         | oid    |           | not null | 
 castsource  | oid    |           | not null | 
 casttarget  | oid    |           | not null | 
 castfunc    | oid    |           | not null | 
 castcontext | "char" |           | not null | 
 castmethod  | "char" |           | not null | 
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 12)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default 
-------------+--------+-----------+----------+---------
 oid         | oid    |           | not null | 
 castsource  | oid    |           | not null | 
 casttarget  | oid    |           | not null | 
 castfunc    | oid    |           | not null | 
 castcontext | "char" |           | not null | 
 castmethod  | "char" |           | not null | 
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 11)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default 
-------------+--------+-----------+----------+---------
 castsource  | oid    |           | not null | 
 casttarget  | oid    |           | not null | 
 castfunc    | oid    |           | not null | 
 castcontext | "char" |           | not null | 
 castmethod  | "char" |           | not null | 
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 10)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default 
-------------+--------+-----------+----------+---------
 castsource  | oid    |           | not null | 
 casttarget  | oid    |           | not null | 
 castfunc    | oid    |           | not null | 
 castcontext | "char" |           | not null | 
 castmethod  | "char" |           | not null | 
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 9.6)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 9.5)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 9.4)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 9.3)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 9.2)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 9.1)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 9.0)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 8.4)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 8.3)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

pg_cast (PostgreSQL 8.2)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers 
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

文档: pg_cast

更改历史

示例

列出所有 xml 转换

postgres=# SELECT castsource::regtype, casttarget::regtype, castfunc::regproc,
                  castcontext, castmethod
             FROM pg_catalog.pg_cast
             WHERE castsource = 'xml'::regtype OR casttarget = 'xml'::regtype
          ORDER BY castsource::regtype::TEXT;

    castsource     |    casttarget     | castfunc | castcontext | castmethod 
-------------------+-------------------+----------+-------------+------------
 character         | xml               | xml      | e           | f
 character varying | xml               | xml      | e           | f
 text              | xml               | xml      | e           | f
 xml               | text              | -        | a           | b
 xml               | character varying | -        | a           | b
 xml               | character         | -        | a           | b
(6 rows)

postgres=# \dC xml
                               List of casts
    Source type    |    Target type    |      Function      |   Implicit?   
-------------------+-------------------+--------------------+---------------
 character         | xml               | xml                | no
 character varying | xml               | xml                | no
 text              | xml               | xml                | no
 xml               | character         | (binary coercible) | in assignment
 xml               | character varying | (binary coercible) | in assignment
 xml               | text              | (binary coercible) | in assignment
(6 rows)

分类

系统目录

反馈

请在此处提交关于 "pg_cast" 的任何评论、建议或更正 此处