This is a homework problem that I'm inputting on oracle live sql website:
Create table student (regno number (6), mark number (3) constraint b check (mark >=0 and
mark <=100));
Alter table student add constraint b2 check (length(regno<=4));
It keeps throwing a "missing right parenthesis" error on the second line to Alter. I read elsewhere this is a generic error for syntax but for the life of me, even if I copy and paste the code from the source material into the SQL worksheet or retype it about 20 times now, I keep getting the error.
I also tried casting to char as regno is a number.
Alter table student add constraint b2 check (length(to_char(regno)<=4));
But I get the same error.
You comparison operator(
<=) should be outside thelengthfunction:One suggestion, If you want to restrict the
REGNOto only 4 digits then convert the data type ofREGNOasNUMBER(4)Cheers!!