mysql vet -> oracle newbie [message #170669] |
Thu, 04 May 2006 13:45 |
chovy
Messages: 6 Registered: May 2006
|
Junior Member |
|
|
Any guides on the basic differences between mysql and oracle?
I've noticed quite a few already, with basic sql instructions.
for example mysql's AUTO_INCREMENT column type is not to be found in Oracle.
|
|
|
|
|
|
|
|
Re: mysql vet -> oracle newbie [message #170681 is a reply to message #170674] |
Thu, 04 May 2006 15:36 |
Ronald Beck
Messages: 121 Registered: February 2003
|
Senior Member |
|
|
If you want to have an auto-increment field perform exactly the same as your mySQL, you'll need a trigger to automatically add a value when you insert data into the table.
Oracle triggers are valuable tools as they let you a wide variety of things based on changes to the table you've attached the trigger to. In addition to auto-increment fields, I've used triggers to copy an old record to a history table prior to making an update to the information.
If you're willing to make some changes to the SQL code from your mySQL version to an Oracle version, you can always use "<sequence_name>.NEXTVAL" in your insert statement. Thus, if you have a table with the columns SEQUENCE, DATA1, DATA2, in mySQL, the insert statement is insert into TABLE (DATA1, DATA2) values ('some text','some name'). Oracle would be insert into TABLE (SEQUENCE, DATA1, DATA2) values (table_seq.NEXTVAL, 'some text','some name').
The good thing about using an Oracle sequence is that you don't have to start with 1 every time.
Hope this helps,
Ron
|
|
|
Re: mysql vet -> oracle newbie [message #170729 is a reply to message #170674] |
Fri, 05 May 2006 00:00 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
chovy wrote on Thu, 04 May 2006 21:30 | thanks.
Do i really have to create a trigger for each table i want an incremental index on?
|
I'm afraid so. Also, take into consideration that a sequence is not gap-free. An auto-incremented ID-column should not have a requirement to be gap-free, but it is something a lot of new (Oracle-)users wonder and complain about.
|
|
|
|
Re: mysql vet -> oracle newbie [message #170894 is a reply to message #170891] |
Fri, 05 May 2006 17:01 |
chovy
Messages: 6 Registered: May 2006
|
Junior Member |
|
|
i'm using an earlier version of oracle. i suspect it's irrelevant though unless sequence syntax has changed.
yes, i'm new to oracle.
one thing i don't know is how to format the results of a query, tabs, etc.
|
|
|
|