如何使用 Enum 值在 oracle 中添加一列?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18904003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:56:05  来源:igfitidea点击:

How do i add a column in oracle with Enum values?

sqloracleenums

提问by Jess

How to use enums in Oracle?

如何在 Oracle 中使用枚举?

The above post gives me an option to create a Enum column while creating a table. But I have a table that is having values. I wanted to add another column with Enum values.

上面的帖子为我提供了在创建表时创建 Enum 列的选项。但我有一张有值的表。我想添加带有 Enum 值的另一列。

ALTER TABLE CARS **(ADD** BODY_TYPE VARCHAR2(20) 
                    CHECK (BODY_TYPE IN ('COUPE','SEDAN','SUV')) );

I'am getting a syntax error near ADD. Please guide.

我在 附近遇到语法错误ADD。请指导。

回答by Tomasz ?uk

Place "add" before "(".

将“添加”放在“(”之前。

alter table cars
add
(
  body_type varchar2(20) not null check (body_type in ('COUPE','SEDAN','SUV'))
);