Home » SQL & PL/SQL » SQL & PL/SQL » Oracle SQL Developer questions (Oracle SQL Developer)
Oracle SQL Developer questions [message #607921] Thu, 13 February 2014 08:41 Go to next message
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 Go to previous messageGo to next message
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 #607924 is a reply to message #607923] Thu, 13 February 2014 08:54 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to the forum.

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/

Re: Oracle SQL Developer questions [message #607925 is a reply to message #607923] Thu, 13 February 2014 09:02 Go to previous messageGo to next message
Lahkra
Messages: 10
Registered: February 2014
Junior Member
Ok, thanks for the help, but from what you say I have another question.

Why does it accept calling an attribute Unique and NOT NULL in one table and have that attribute later be made the Primary Key, but not in another table?
For example, CREATE TABLE OUTAGE didn't have this problem.
Re: Oracle SQL Developer questions [message #607926 is a reply to message #607924] Thu, 13 February 2014 09:07 Go to previous messageGo to next message
Lahkra
Messages: 10
Registered: February 2014
Junior Member
I'm sorry, from the link you provided I only see that I didn't add my Oracle version and didn't put the code in a text file, though it can be opened by simply choosing Edit. Is there something I missed other than this? Also, I don't see an edit option on my post.
Re: Oracle SQL Developer questions [message #607927 is a reply to message #607926] Thu, 13 February 2014 09:12 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I don't see an edit option on my post.
This forum software only allows edits when no reply has been posted.
Just add new details to the end of the thread.
Re: Oracle SQL Developer questions [message #607928 is a reply to message #607926] Thu, 13 February 2014 09:14 Go to previous messageGo to next message
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 #607929 is a reply to message #607927] Thu, 13 February 2014 09:21 Go to previous messageGo to next message
Lahkra
Messages: 10
Registered: February 2014
Junior Member
I am using Oracle 4.0.0.13 and here is the code in a text file.
Re: Oracle SQL Developer questions [message #607931 is a reply to message #607929] Thu, 13 February 2014 09:30 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
That's be the sql developer version, the db version would be more useful. Run this to get it:
SELECT * FROM v$version;


As for the output, it's better to post it directly in code tags as described here: How to use [code] tags and make your code easier to read?

Not everyone can/will download files
Re: Oracle SQL Developer questions [message #607932 is a reply to message #607931] Thu, 13 February 2014 09:41 Go to previous message
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.
Previous Topic: Single quote issue in oracle
Next Topic: n00b question
Goto Forum:
  


Current Time: Thu Apr 18 17:49:20 CDT 2024