Question:
Error code in Oracle SQL?
anonymous
2011-01-21 11:03:58 UTC
Here's the thing I'm trying to do with Oracle SQL.
CREATE TABLE options
(Ocode CHAR(4) PRIMARY KEY,
Odesc VARCHAR2(48),
Ocost NUMBER(7,2)
Olist NUMBER(7,2));

It spits out the following:
(Ocode CHAR(4) PRIMARY KEY,
*
ERROR at line 2:
ORA-00922: missing or invalid option

What's the issue here?
Three answers:
randi
2011-01-23 21:03:58 UTC
try this, it works i did a test run





CREATE TABLE options

(Ocode CHAR(4) primary key ,

Odesc VARCHAR2(48),

Ocost NUMBER(7,2),

Olist NUMBER(7,2));
Fletch
2011-01-21 11:15:58 UTC
Try this:





CREATE TABLE options

( Ocode CHAR(4) not null,

Odesc varchar2(48) not null,

Ocost Number(7,2),

Olist Number(7,2),

CONSTRAINT Ooptions_pk PRIMARY KEY (Ocode)

);
TheMadProfessor
2011-01-21 11:20:39 UTC
As it is wont to do, Oracle has its own way of doing some things. Instead of the PRIMARY KEY clause, just specify the column as NOT NULL and add a CONSTRAINT - PRIMARY KEY clause as one of the last statements in the CREATE TABLE. See http://techonthenet.com/oracle/primary_keys.php for particulars.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...