💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
> [TOC] ## 枚举类型 创建枚举语法 ``` CREATE TYPE name AS ENUM ( label_1 [, label_2, ... ] ); ``` ### 添加枚举类型 ``` CREATE TYPE my_week AS ENUM ( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ); ``` ### 查看枚举类型 ``` > select * from pg_enum; ``` ### 创建带枚举类型的表 ``` CREATE TABLE week_day_sales ( id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY, week_day my_week NOT NULL, sales integer NOT NULL ); ``` ### 插入数据 ``` INSERT INTO week_day_sales (week_day, sales) VALUES ('Monday', 110), ('Tuesday', 120), ('Wednesday', 130); ```