Madhusudan
Madhusudan

Reputation: 4815

How to delete a custom data type in PostgreSQL?

I have created a datatype in PostgreSQL using folloing line:

CREATE TYPE ABC AS (A CHARACTER(1), B CHARACTER(2), C BIGINT);

I didn't define this datatype. Now I want to delete this prototype. What is the way or command to delete this?

Upvotes: 8

Views: 16172

Answers (4)

Iury Vieira
Iury Vieira

Reputation: 46

Note:

Ensure to put quotes in type name to correctly search on database, otherwise it will throw that doesn't exist.

Example:

DROP TYPE "NameOfType" CASCADE;

Upvotes: 0

m4salah
m4salah

Reputation: 106

You can provide the schema name first

DROP TYPE schema_name.type_name;

Upvotes: 0

Kamil Gosciminski
Kamil Gosciminski

Reputation: 17157

You can remove a data type using

DROP TYPE type_name;

Click here for manual reference for DROP TYPE

Remember, that if you have other objects that depend on the type you are trying to delete, it would yield an error

ERROR:  cannot drop type type_name because other objects depend on it

with list of dependencies.

If you would also like to DROP those objects type

DROP TYPE type_name CASCADE;

Upvotes: 22

Robert
Robert

Reputation: 25753

Try remove this TYPE this way

DROP TYPE ABC;

Upvotes: 4

Related Questions