bgdf 05
bgdf 05

Reputation: 11

Specific value for Y or N in SQL

The task is: a new table, BENEFITS, must be created to store the available benefit plan options and must contain the following columns:

So far I have

CREATE TABLE Benefits
(
    Ben_id NUMBER(2),
    Ben_plan VARCHAR2(1),
    Ben_provider NUMBER(3),
    Active VARCHAR2(1)
);

But how can I make the Active only accepts Y or N? I'm learning on using the CONSTRAINT, just still can't understand it.

Upvotes: 0

Views: 33

Answers (1)

bgdf 05
bgdf 05

Reputation: 11

CREATE TABLE Benefits
    (Ben_id NUMBER(2),
    Ben_plan VARCHAR2(1),
    Ben_provider NUMBER(3),
    Active VARCHAR2(1) CHECK (Active = 'Y' OR Active = 'N'));

Upvotes: 1

Related Questions