按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
更改历史
- PostgreSQL 8.4
- 添加了列
castmethod
(提交 092bc496)
- 添加了列
- PostgreSQL 7.3
- 添加 (提交 97377048)
示例
列出所有 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)
参考
- PostgreSQL 文档: pg_cast