Especificar restricciones en la cláusula CREATE en SQL [cerrado]

I'm trying to set the Quantity attribute to limit from 1 to 100. Does anyone know why this code isn't working?

  OrderID     VARCHAR2(4),
  ProductID   VARCHAR2(2),
  Quantity    INTEGER,
  CONSTRAINT check_quantity CHECK((INTEGER > 0) AND (INTEGER < 101)));

preguntado el 09 de enero de 11 a las 06:01

1 Respuestas

Tal vez quieras CHECK((Quantity > 0) AND (Quantity < 101)) ?

Equivalently, you could write CHECK(Quantity BETWEEN 1 AND 100)

Respondido el 09 de enero de 11 a las 09:01

o that right. haha thanks! by the way is there a difference between int and integer? - Ronnie

@Ronnie, Sorry, I don't know - I'm more of a SQL Server guy, and unlike your original question, that would be Oracle-specific... - Jon

@Ronnie: The actual Oracle data type is NUMBER -- INT, INTEGER, etc are accepted synonyms. Ever database that I can think of that supports INT as a synonym for INTEGER. - Ponis dios mio

if the problem request whole numbers from 1 to 100, should i use number or integer? since the scale is 0 if i put number(3)? - Ronnie

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.