SAP HANA SQL Vs. ORACLE SQL

Aus http://www.techies.com

SAP HANA SQL vs Oracle SQL

SQL statements created in Oracle wont work with SAP HANA it will return unexpected results, here are some transaction difference between Oracle and SAP HANA in SQL Queries.

 Oracle SQLSAP HANA SQL
Dummy query tableDUMMYDUAL
Condition functionDECODEMAP
Check for NULL valueNVLIFNULL
Limit on result setWHERE ROWNUM <= <num_records>SELECT TOP <num_records>
Limit on result set with sortingSELECT … FROM ( SELECT … FROM … WHERE … ORDER BY … ) WHERE ROWNUM <= <num_records>SELECT TOP <num_records> FROM xxx WHERE xxx ORDER BY
Analytical function for calculating ratioRATIO_TO_REPORTnot available; can be reproduced using analytical SUM function
Analytical function for linking stringsLISTAGG (>= 11.2)STRING_AGG (>= rev. 72)
Multilevel queriesCONNECT BYno direct implementation, SAP Note 2073410 describes alternative
TO_DATE functionResult can contain date and time (depending on NLS_DATE_FORMAT)Result is only the date; time is 00:00:00; use TO_TIMESTAMP.
Result is only the date; time is 00:00:00; use TO_TIMESTAMP.DUMP(<value>)DUMP(<value>)
DeadlocksTermination of an involved DML operation, continuation of current transactionTermination of transaction
Behavior for long-running exclusive lock waitsLong wait for release of lockTermination for timeout (parameter lock_wait_timeout, default: 30 minutes)
Table with Explain informationPLAN_TABLEEXPLAIN_PLAN_TABLE
Define default schema for queriesALTER SESSION SET CURRENT_SCHEMA = <schema_name>SET SCHEMA <schema_name>
RoundingIf required, the system rounds the value (INSERT of 1.9 in DECIMAL (5,0) columns -> SELECT returns 2)If required, the system truncates the value (INSERT of 1.9 in DECIMAL (5,0) columns -> SELECT returns 1)
Accuracy of INTEGER calculationsHigh accuracy (SELECT 1 / 10000000 * 10000000 results in 1)6 decimal places (SELECT 1 / 10000000 * 10000000 results in 0)
Unique IDROWIDInternal $rowid$ column (column store), no equivalent in the row store
Behavior for an incorrect database hintHint is (usually) ignoredError (468 : hint error: invalid hint)
Copying a tableDBMS_METADATA.GET_DDL or CREATE TABLE … AS SELECTCREATE TABLE xxx LIKE xxx [WITH DATA]
Determination of object definitionsDBMS_METADATA.GET_DDL(‚<object_type>‘, ‚<object_name>‘, ‚<object_owner>‘)GET_OBJECT_DEFINITION( ‚<object_owner>‘, ‚<object_name>‘, ‚<object_type>‘)
SAP HANA deletes trailing blanksDECODE(‚   ‚, “, ‚empty string‘, ‚blanks‘)MAP(‚   ‚, “, ‚empty string‘, ‚blanks‘)
Empty string and NULLDECODE(“, NULL, ‚NULL value‘, ‚empty string‘)MAP(“, NULL, ‚NULL value‘, ‚empty string‘)
Concatenating a string with NULL results in NULL on SAP HANANVL(‚abc‘ || NULL, ‚NULL value‘)IFNULL(‚abc‘ || NULL, ‚NULL value‘)