check constraint

Started by Martin A. Marquesover 25 years ago5 messagesgeneral
Jump to latest
#1Martin A. Marques
martin@math.unl.edu.ar

Hi,
how should I write a constraint that can keep an INT field with values
between 0 and 10? Do I have to use two checks on the same field?

TIA

--
System Administration: It's a dirty job,
but someone told I had to do it.
-----------------------------------------------------------------
Mart�n Marqu�s email: martin@math.unl.edu.ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------

#2Wade D. Oberpriller
oberpwd@anubis.network.com
In reply to: Martin A. Marques (#1)
Re: check constraint

You should be able to do the following:

CREATE TABLE table1 (
field1 INTEGER CHECK ((field1 >= 0) AND (field1 <= 10))
);

Wade Oberpriller

Show quoted text

Hi,
how should I write a constraint that can keep an INT field with values
between 0 and 10? Do I have to use two checks on the same field?

TIA

--
System Administration: It's a dirty job,
but someone told I had to do it.
-----------------------------------------------------------------
Mart�n Marqu�s email: martin@math.unl.edu.ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------

#3Martin A. Marques
martin@math.unl.edu.ar
In reply to: Wade D. Oberpriller (#2)
Re: check constraint

El Lun 18 Dic 2000 12:43, Wade D. Oberpriller escribi�:

You should be able to do the following:

CREATE TABLE table1 (
field1 INTEGER CHECK ((field1 >= 0) AND (field1 <= 10))
);

Thanks!!! Didn't know that!!!!!

--
System Administration: It's a dirty job,
but someone told I had to do it.
-----------------------------------------------------------------
Mart�n Marqu�s email: martin@math.unl.edu.ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------

#4Martin A. Marques
martin@math.unl.edu.ar
In reply to: Wade D. Oberpriller (#2)
Re: check constraint

El Lun 18 Dic 2000 12:43, Wade D. Oberpriller escribi�:

You should be able to do the following:

CREATE TABLE table1 (
field1 INTEGER CHECK ((field1 >= 0) AND (field1 <= 10))
);

Can I put an OR there?

--
System Administration: It's a dirty job,
but someone told I had to do it.
-----------------------------------------------------------------
Mart�n Marqu�s email: martin@math.unl.edu.ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------

#5Tulio Oliveira
mestredosmagos@marilia.com
In reply to: Martin A. Marques (#4)
Re: Re: check constraint

"Martin A. Marques" wrote:

El Lun 18 Dic 2000 12:43, Wade D. Oberpriller escribi�:

You should be able to do the following:

CREATE TABLE table1 (
field1 INTEGER CHECK ((field1 >= 0) AND (field1 <= 10))
);

Can I put an OR there?

--
System Administration: It's a dirty job,
but someone told I had to do it.
-----------------------------------------------------------------
Mart�n Marqu�s email: martin@math.unl.edu.ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------

Off course NOT.

If you put an OR, all numbers will be accept....

--
======================================================
AKACIA TECNOLOGIA
Desenvolvimento de sistemas para Internet
www.akacia.com.br