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

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL newbie

Re: SQL newbie

From: Howard J. Rogers <howardjr2000_at_yahoo.com.au>
Date: Mon, 25 Nov 2002 04:59:16 +1100
Message-ID: <mj8E9.83108$g9.234036@newsfeeds.bigpond.com>


Yup, it's an error alright.

If you want to find out how to use a sequence to supply a primary key to a table, please visit www.jlcomp.demon.co.uk -Jonathan Lewis hosts the newsgroup collaborative FAQ there, and this very question is answered there (see in particular the answer to How do you create an 'auto number' or 'auto increment' column similar to the offering from Microsoft's SQL Server ?)

The short answer is that you don't do it as part of the create table statement, but need a before insert trigger to effect the insertion of the sequence number.

Regards
HJR "Miss. Michelle Heigardt" <michelleheigardt_at_hotmail.com> wrote in message news:87d7e814.0211240926.a7cc2a8_at_posting.google.com...
> Hallo, I have the following SQL for creating a table. If you can help
> me sort out what is wrong I would helpfull.
>
> create sequence testsequence;
> create table testtable(a number primary key, b number
> testsequence.nextval);
> insert into testtable values (1034);
> insert into testtable values (1045);
> insert into testtable values (32);
>
> The error that Oracle says is:
>
> create table testtable(a number primary key, b number
> testsequence.nextval)
> *
> ERROR at line 1:
> ORA-00922: missing or invalid option
Received on Sun Nov 24 2002 - 11:59:16 CST

Original text of this message

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