如何使用ENUM使用默认选项添加列

问题描述

我想在表中添加一列称为类别,但我尝试了几种选择,但不起作用

 alter table attachments
                add
                (
                  category varchar2(20) not null check (category in ('default','agreement','security','@R_947_4045@ion') DEFAULT 'default')
                );

我也尝试这样的事情

 ALTER TABLE attachments
 ADD  category ENUM ('default','@R_947_4045@ion') DEFAULT 'default'

在这里检查了几篇文章,但找不到任何解决方案。我在哪里弄错了?这是怎么了? 我收到消息

Error report -
ORA-00907: missing right parenthesis
00907. 00000 -  "missing right parenthesis"
 

解决方法

您可以这样表达:

alter table attachments
add category varchar2(20) 
    default 'default'
    check (category in ('default','agreement','security','information'))
    not null 
;