sql - add check constraint, get invalid data type error -


using oracle sqldeveloper

table t has 2 columns id (number) desc (varchar2)

i try following query add check:

alter table t add constraint 100chk check (id between 0 , 100); 

error report: sql error: ora-00902: invalid datatype 00902. 00000 - "invalid datatype" *cause:
*action:

the id column number datatype - why isn't letting me add constraint?

oracle getting confused constraint name 100chk. valid names start letter. can put double quotes around invalid name , oracle accept it, considered bad idea.

try naming constraint chk100 instead:

alter table t add constraint chk100 check (id between 0 , 100); 

oracle's object naming rules here. link 10.2 information holds 11.x well.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -