How to create a enum field with default value?

I was trying the same as you, and I got answer in stackoverflow only, It is possible to create ENUM with default value. Here is what I got for you.

CREATE TYPE status AS ENUM ('Notconfirmed','Coming', 'Notcoming', 'Maycome');

CREATE TABLE t (
    id serial,
    s status default 'Notconfirmed' -- <==== default value
);

INSERT INTO t(id) VALUES (default) RETURNING *; 

This worked for me like a charm.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)