Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: auto increment? 'enum' data type?

Re: auto increment? 'enum' data type?

From: SKurosky <skurosky_at_aol.com>
Date: 26 Jan 2000 18:43:42 GMT
Message-ID: <20000126134342.14624.00000060@ng-co1.aol.com>


>OTIS WROTE:

>Hi,
>
>I'm new to Oracle and am wondering what's the best/easiest way to make a
>column 'auto increment' (e.g. an ID column used as a primary key)?
>Do I have to make a sequence in my schema for that particular
>column/table/database? Or can I specify something like 'AUTO INCREMENT'
>when I do CREATE TABLE .... (doesn't seem to be the case).
>
>I am also wondering if there is a data type that will let me specify a
>list of all possible values that a column can have, so that no other
>value can be inserted in that column?
>In MySQL I would do somehting like this, for example:
> gender enum('Male','Female')
>How about under Oracle?
>
>Thanks,
>
>Otis
>P.S.
>I ordered an Oracle book, it's just hasn't been delivered yet...
>
>
>Sent via Deja.com

Yes..

   CREATE SEQUENCE sequence_name
   INCREMENT BY some_value
   START WITH some_value
   MAXVALUE some_value
   NOCYCLE
   ..... there are others options   

   Place a check constraint in your table definition for the column or use ALTER TABLE table_name ADD CONSTRAINT... if table created already.

 hth
Sandy Received on Wed Jan 26 2000 - 12:43:42 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US