Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL newbie
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