MySQL Oracle equivalents

The title of this article implies something rather odd and upcoming considering that Sun Microsystems bought MySQL and Oracle bought Sun. But in fact, this is just a quick list of some regular commands in MySQL that I need in Oracle:

- See if a table existsSHOW TABLESSelect table_name from sys.dba_tables
- Return a specific number of rowsSELECT * FROM table1 LIMIT 0, 10 SELECT * FROM table1 WHERE ROWNUM<=10 (didnt work for me in Oracle 10g)
- Quick if-then-else ELT(N,str1,str2,str3,...) decode( expression , compare_value, return_value, [,compare, return_value] ... [,default_return_value] )
- Seconds since Unix began SELECT UNIX_TIMESTAMP(); FLOOR ( ( SYSDATE - TO_DATE('01-JAN-1970 00:00:00','DD-MON-YYYY HH24:MI:SS') ) * (24*60*60) )
- Replace a table row REPLACE INTO table1 (col1, col2, ...) VALUES ('value1', 'value2', ...) MERGE INTO table1 USING <table_view_or_query> ON (<condition>) WHEN MATCHED THEN <update_clause> DELETE <where_clause> WHEN NOT MATCHED THEN <insert_clause>
- Delete a table if it exists DROP TABLE IF EXISTS `table1` DECLARE v_count NUMBER :=0; BEGIN SELECT COUNT(*) INTO v_count FROM all_tables WHERE table_name='Drop_Me' AND owner='Me'; IF v_count = 1 THEN EXECUTE IMMEDIATE 'DROP TABLE Me.Drop_Me'; END IF; END; Read more: How to Drop a Database Table Only If It Already Exists |

Assuming "table1" is a table randomly selected.

Credit where Credit is Due:

Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman

Related Articles

Joes Revolver Map


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 bc1qjtp4l4ra452wzvuk9a45yfj82zkahsyy2z379y
© 2022 Joel Lipman .com. All Rights Reserved.