Sunday, February 8, 2009

SQL Syntax: MySQL vs. Oracle

This may seem obvious to a lot of folks, but I never realized that a lot of syntax I assumed was standard SQL syntax is only specific to MySQL. So I assumed something like "UPDATE table SET field = 'Damian\'s Text' WHERE id = 1;" would work in Oracle, but no such luck. Two single quotes does the escape trick in Oracle rather than a backslash. Not to mention Oracle requires a "COMMIT;" after any insert or update (and maybe other commands).

You can also forget about using LIMIT within your statements in Oracle. Again, this was another function I thought was standard SQL. ROWNUM does a similar thing, but in a more convoluted way.

Bottom line, if you're used to MySQL, you may have to check a bunch of your syntax to see what works with Oracle, and vice versa. There's got to be a page out there that shows syntax differences between these two (and other) database types.

No comments:

Post a Comment