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

问题描述

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

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

我也尝试这样的事情

 ALTER TABLE attachments
 ADD  category ENUM ('default','information') 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 
;

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...