Sunday, September 15, 2013

Some differencies in Oracle and Teradata SQL queries

This is not complete list of course. There are a lot of other features which work differently in these databases. For instance, analytic functions of Oracle will definitely require extra manual work if you are going to migrate queries. From the other hand, Oracle as well as Teradata are constantly updating list of available SQL features. For example, DECODE function had to be transformed to CASE statement in Teradata, but now version 14 knows how to handle it. 

 Oracle Teradata Possible error message
Allows WITH clause without column names: with SUBQUERY_NAME as (select a,b from c) select * from SUBQUERY_NAME; Subquery name in WITH clause must be provided by column names: with SUBQUERY_NAME(a,b) as (select a,b from c) select * from SUBQUERY_NAME; [Teradata Database] [3706] Syntax error: expected something between the word 'SUBQUERY_NAME' and the 'as' keyword.
Allows ORDER BY clause in subqueries: select * from (select column1, column2 from table_name order by column1); There might be only one ORDER - in the main query. [Teradata Database] [3706] Syntax error: ORDER BY is not allowed in subqueries.
SYSDATE CAST(CURRENT_TIMESTAMP(0) AS TIMESTAMP(0)) [Teradata Database] [5628] Column sysdate not found in table_name.
DateTime +/- n/86400 DateTime +/- interval 'n' second [Teradata Database] [5407] Invalid operation for DateTime or Interval.
DateTime +/- n/1440 DateTime +/- interval 'n' minute [Teradata Database] [5407] Invalid operation for DateTime or Interval.
DateTime +/- n/24 DateTime +/- interval 'n' hour [Teradata Database] [5407] Invalid operation for DateTime or Interval.
DateTime +/- n DateTime +/- interval 'n' day [Teradata Database] [5407] Invalid operation for DateTime or Interval.
Subqueries are allowed without aliases: select * from (select * from table_name); All subqueries must be provided by alias: select * from (select * from table_name) t1; [Teradata Database] [3707] Syntax error, expected something like a name or a Unicode delimited identifier or an 'UDFCALLNAME' keyword between ')' and ';'.

No comments:

Post a Comment