Oracle – How to Add ENUM Attribute to Existing Table Using ALTER

alter-tableenumoracle

I am using oracle XE and trying to add a attribute that restricts to only three available value 'Small','Medium','large' to an existing table using Alter Table and Enum.

Tried doing,

ALTER TABLE TRUCK ADD TTYPE ENUM('SMALL','MEDIUM','LARGE');

but gets invalid option

ALTER TABLE TRUCK ADD TTYPE ENUM('SMALL','MEDIUM','LARGE');
                                 *

where the error highlights after ENUM.

I think I am having syntax error. Please help to resolve.

Best Answer

I think you want this:

ALTER TABLE TRUCK 
    ADD (ttype VARCHAR2(6) 
    CONSTRAINT con_type 
    CHECK (ttype in('SMALL','MEDIUM','LARGE'))
    );