Oracle SQL Developer questions [message #607921] |
Thu, 13 February 2014 08:41 |
|
Lahkra
Messages: 10 Registered: February 2014
|
Junior Member |
|
|
I have run my code, and came up with some errors, though the code was written like the examples in the book I have (Database Systems: Design, Implementation and Management 10e). Some of the errors our professor said would be expected- the error on each table when dropping them when one does not exist, then the next line creates it. This is to be able to reuse the tables at a later date. If someone has the book mentioned, I have been looking around pages 236 for an example of code. Attached is my code and the errors- my questions on the errors are lines: 8, 21, 28, 42 & 55.
As can be seen from the file I get 2 errors on the Primary Key, 2 on a "missing keyword" on Foreign Keys, and one on an "invalid relational operator".
First on the Primary Key, as mentioned I am looking at the book example and in the table creation the attribute is created, then it is made the Primary Key at the bottom of the table creation. Since the attribute is made Unique, is it already set as the Primary key in Oracle SQL Developer, so I do not have to do as the book and set the attribute as the Primary Key later in the table?
Next on the Foreign Key, again I am using the book example. Is there a different way to enter the code for the Foreign Key to not get this error?
Finally, I am using the example of CHECK from the book (pg 240), so what am I missing if all I have is from the book?
Thank you.
|
|
|
Re: Oracle SQL Developer questions [message #607923 is a reply to message #607921] |
Thu, 13 February 2014 08:51 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
1) I have never used unique like that, lose it and just create a unique constraint or primary key seperately.
2) On update cascade is not valid oracle syntax and never has been. On delete cascade is.
3) CHECK(OUTAGE_CAUSS ('D','S')) isn't valid syntax either. Should be CHECK(OUTAGE_CAUSS IN ('D','S')).
Personally I would suggest learning the oracle syntax for creating/altering tables from either the oracle documentation or an oracle specific textbook.
|
|
|
|
|
|
|
Re: Oracle SQL Developer questions [message #607928 is a reply to message #607926] |
Thu, 13 February 2014 09:14 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Unique after a column makes that column unique.
Making a single column unique is different to making multiple columns unique.
If you have a table with 2 columns with the combination of the two being unique you can enter the following:
COLA COLB
1 1
1 2
If each individual column is unique then the 2nd row will violate the unique key on cola.
Which is way the outage table creates but is fundamentally wrong.
|
|
|
|
|
Re: Oracle SQL Developer questions [message #607932 is a reply to message #607931] |
Thu, 13 February 2014 09:41 |
|
Lahkra
Messages: 10 Registered: February 2014
|
Junior Member |
|
|
Unfortunately, I have to use what system the school uses, so I can't change to the db version. Thanks for the tips and all of the help. I worked it out, though perhaps not exactly as what the professor is expecting, but I get no errors now.
|
|
|