Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a custom data type in PostgreSQL?

Tags:

sql

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?

like image 739
Madhusudan Avatar asked Dec 05 '22 03:12

Madhusudan


1 Answers

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;
like image 194
Kamil Gosciminski Avatar answered Dec 17 '22 17:12

Kamil Gosciminski