如何在Redshift中创建枚举?

3

我想在Redshift上创建一个枚举类型,但无法实现。

CREATE TYPE status AS ENUM ('Yes', 'No');

错误信息是:
An error occurred when executing the SQL command:
CREATE TYPE status AS ENUM ('Yes', 'No')

ERROR: syntax error at or near "ENUM"
  Position: 23

CREATE TYPE status AS ENUM ('Yes', 'No')
                  .    ^
1 statement failed

我使用的版本是:
PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.1885

无法确定查询是否错误或不受此版本支持?

1个回答

8

Redshift文档所述,Redshift不支持枚举类型。

不幸的是,Redshift不支持我想到的两种解决方法:检查约束和外键约束(其中值存储在引用表中)。

我的建议是为类型创建一个引用表,并使用外键引用。尽管Redshift不强制执行约束,但至少意图是清晰的。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接