|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello All,
I have two small problems when attemting to create the following tables: #1 String orderT = "CREATE TABLE order " + "(OID INTEGER(6) not null, " + "CID INTEGER(6), " + "EID INTEGER(6) not null, " + "PID INTEGER(6) not null, " + "WID INTEGER(6), " + "number INTEGER(6) not null, " + "issueDate date DEFAULT SYSDATE not null, " + "paymentStatus VARCHAR2(25), " + "deliveryStatus VARCHAR2(25), " + "completionDate date " + "PRIMARY KEY (OID))"; When I try to create this table I get an error that says "invalid table name". No ideas here. #2 String storedAtT = "CREATE TABLE storedAt " + "(PID INTEGER(6) not null, " + "WID INTEGER(6) not null, " + "numberStored INTEGER(6) DEFAULT 0 not null, " + "PRIMARY KEY (PID, WID))"; When I try to create this table I get an error that says "missing right parenthesis". I have a feeling it is due to the DEFAULT 0 not null part. Any help is appreciated! Thanks Chris |
|
#2
|
|||
|
|||
|
ORDER is a reserved word!
You have to choose a different table name |
|
#3
|
|||
|
|||
|
Ta, should have picked that one up...
Now I get the "missing right parenthesis" for both queries. Any Ideas? Chris |
|
#4
|
|||
|
|||
|
String orderT = "CREATE TABLE order
(OID INTEGER(6), CID INTEGER(6), EID INTEGER(6), PID INTEGER(6), WID INTEGER(6), number INTEGER(6), issueDate date DEFAULT SYSDATE, paymentStatus VARCHAR2(25), deliveryStatus VARCHAR2(25), completionDate date CONSTRAINT ORDER_PK PRIMARY KEY (OID), CONSTRAINT ORDER_NN NOT NULL (EID, PID, NUMBER, ISSUEDATE) ); From what i've been taught of Oracle, I would have thought it went like that ... but what do I know? Also, I wouldn't have thought you'd create a primary key and also add a Not Null constraint, won't it already have that with it being a primary key? |
|
#5
|
|||
|
|||
|
You need a comma after completionDate date
And no, a primary key does not imply a NOT NULL. A pimary key only implies that the key values are unique. One could image a situation where it might be interesting to flag certaing data with a PK that is NULL (but only one!) |
|
#6
|
|||
|
|||
|
Hi Guys,
That was on the money but there was one more bug... number is a reserved word!! Cheers Chris |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Table Creation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|