4

I want to add a column to a table, then add a check constraint to make sure its greater than 0. I cant seem to get this to run in oracle sl developer.

Alter TABLE store101
add column Base_salary Number(7,2)
constraint store101_Base_salary_ck
check (Base_salary > 0);

Error report - SQL Error: ORA-00904: : invalid identifier 00904. 00000 - "%s: invalid identifier"

1 Answer 1

7

There is no ADD COLUMN clause in ALTER TABLE syntax. It's just ADD.

ALTER TABLE store101
ADD Base_salary NUMBER(7, 2) -- there is no need to add COLUMN clause
CONSTRAINT store101_Base_salary_ck 
CHECK (Base_salary > 0);

Here is SQLFiddle demo

Sign up to request clarification or add additional context in comments.

1 Comment

That solved it thanks for your help and patience with my lack of knowledge

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.