-- Create table with custom ENUM data type CREATE TYPE mood AS ENUM ('happy', 'sad', 'angry', 'excited'); -- custom ENUM data type CREATE TABLE person ( -- table creation id SERIAL PRIMARY KEY, name VARCHAR(100), current_mood mood ); INSERT INTO person (name, current_mood) VALUES ('Alice', 'happy'); -- data insertion -- Create other custom data type CREATE TYPE phone_number AS ( -- custom type country_code text, area_code text, number text ); CREATE TABLE contacts ( -- creating table contact_id serial PRIMARY KEY, name text, phone phone_number ); INSERT INTO contacts (name, phone) VALUES -- data insertion ('John Doe', ROW('1', '555', '1234567')), ('Jane Smith', ROW('1', '555', '9876543')); SELECT name, (phone).number AS number -- query table with custom data type FROM contacts; -- See user defined data types SELECT typname, typcategory FROM pg_type -- See using information schema SELECT COLUMN_NAME, DATA_TYPE, UDT_NAME, IS_NULLABLE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE FROM INFORMATION_SCHEMA.COLUMNS -- INFORMATION_SCHEMA.TABLES for table information WHERE TABLE_NAME='your_table_name';