Home » SQL & PL/SQL » SQL & PL/SQL » limited input choices for fields
limited input choices for fields [message #227321] Wed, 28 March 2007 00:35 Go to next message
respon
Messages: 3
Registered: March 2007
Junior Member
Hi,

Im creating a table and im trying to say that i only want a varchar2 field to have 2 possible values...i want to say something like this;

CREATE TABLE mytable (
myfield VARCHAR2(6) ("value1" or "value2")
);

Am i able to do something like this?

thanks for your time,
Re: limited input choices for fields [message #227324 is a reply to message #227321] Wed, 28 March 2007 00:49 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Look in the documentation at check constraints.
Re: limited input choices for fields [message #227361 is a reply to message #227324] Wed, 28 March 2007 01:50 Go to previous message
muzahid
Messages: 281
Registered: September 2004
Location: Dhaka, Bangladesh
Senior Member
CREATE TABLE mytable (
myfield VARCHAR2(6)
);

alter table mytable
add CONSTRAINT check_myfield
CHECK ( myfield IN ('value1', 'value2'));
Previous Topic: general query required
Next Topic: How ordering works with NULL vaalue
Goto Forum:
  


Current Time: Wed Dec 07 08:49:59 CST 2016

Total time taken to generate the page: 0.12185 seconds