↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQL Commands

DROP CAST

remove a cast

English manual coverage begins with PostgreSQL 6.4. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

anchor
SQL-DROPCAST
file
sql-dropcast.html
lang
en
name
DROP CAST
purpose
remove a cast
purpose zh
移除一个类型转换
sections same as
Unknown
slug
18
synopsis html
DROP CAST [ IF EXISTS ] (<em class="replaceable"><code>source_type</code></em> AS <em class="replaceable"><code>target_type</code></em>) [ CASCADE | RESTRICT ]
synopsis text
DROP CAST [ IF EXISTS ] (source_type AS target_type) [ CASCADE | RESTRICT ]

Syntax

DROP CAST [ IF EXISTS ] (source_type AS target_type) [ CASCADE | RESTRICT ]
Syntax diagrams

Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.

DROP CAST IF EXISTS ( source_type AS target_type ) CASCADE RESTRICT

Definition PG 18

DROP CAST [ IF EXISTS ] (source_type AS target_type) [ CASCADE | RESTRICT ]

Description

DROP CAST removes a previously defined cast.

To be able to drop a cast, you must own the source or the target data type. These are the same privileges that are required to create a cast.

Parameters

IF EXISTS

Do not throw an error if the cast does not exist. A notice is issued in this case.

source_type

The name of the source data type of the cast.

target_type

The name of the target data type of the cast.

CASCADE
RESTRICT

These key words do not have any effect, since there are no dependencies on casts.

Examples

To drop the cast from type text to type int:

DROP CAST (text AS int);

Compatibility

The DROP CAST command conforms to the SQL standard.

See Also

CREATE CAST

Compare versions

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · wiki-repair-20261023:df5634259b2c5519fcb3736c9cc1cf2bcf5742cd8870b1e1e306dbcfa7282012

Text language: en · wiki-repair-20261023:df5634259b2c5519fcb3736c9cc1cf2bcf5742cd8870b1e1e306dbcfa7282012