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:

ObjectiveMySQLOracle
- 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 | eHow.com http://www.ehow.com/how_4738206_database-table-only-already-exists.html#ixzz10jXVxmgv


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: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience 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
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

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:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.