Search code examples
sqlpostgresqlddlalter

how to modify Type in postgresql?


I have a type defined as:

CREATE TYPE New_A AS
   (id integer,
    id_new integer,
    arrived date,
    sum numeric);

I would like to change arrived from date type to timestamp without time zone type

I tried:

ALTER TYPE New_A SET arrived TO timestamp without time zone

but it doesn't work. it gives:

ERROR: syntax error at or near "arrived"


Solution

  • You can use the alter attribute clause:

    ALTER TYPE new_a ALTER ATTRIBUTE arrived TYPE timestamp without time zone;
    

    For the full details, please refer to the documentation.