![]() |
![]() |
||||
|
Customizing conversion |
|
||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"SwisSQL Console" provides various configuration options to customize the way SQL query conversion is done. This provides users very good flexibility in customizing the query conversion. In this section , you can learn about the various configuration options provided by SwisSQL and how it could be used for customizing the query conversion. All of the listed customizable option can be modified from the SwisSQL Console GUI. All of the configurable options listed below except the option "Setting the default target database" can be modified in the "Conversion settings" dialog. The "Conversion settings dialog" can be accessed through the menu "Settings -> Conversion settings" in the SwisSQL Console GUI. The configurable option "Setting the default target database" can be accessed as described here. Conversion settings dialog![]() These configurations are also available through configuration file SQLOneConsoleOptions.conf present under <InstallationDir>\SwisSQL\Console5.5\conf directory. 1.
Generating Triggers when migrating DB2 IDENTITY column to Oracle
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Description: The sample DB2 SQL creates an employee table with empno column as IDENTITY and a name column. |
|
|
Case 1 – Generating
sequence and trigger : The
option GenerateTriggerForIdentity is
set
to true, which is the default value. In this case the trigger
is
generated along with sequence. |
|
| SOURCE SQL | CONVERTED SQL |
|
CREATE TABLE employee (empno int not null generated always as identity (start with 1 increment by 2),name varchar(20) not null)
|
CREATE SEQUENCE
employee_empno_SEQ |
|
Case 2 - Generating sequence alone: The option GenerateTriggerForIdentity is set to false. In this case the trigger is not generated. |
|
|
CREATE TABLE employee (empno int not null generated always as identity (start with 1 increment by 2),name varchar(20) not null) |
CREATE SEQUENCE
employee_empno_SEQ CREATE TABLE employee |
SwisSQL Console by default converts a CASE statement
of any SQL dialect as DECODE function in Oracle. This default value is
given by following option ConvertCaseToDecode. When the option
is set to true the CASE statement is converted as DECODE
function in Oracle . When the option is set to false the CASE
statement is converted as CASE statement in Oracle.
In the "Conversion
settings" dialog select the check box "Convert CASE
statement to DECODE function in Oracle" to set the value
to true. To set the value to false unselect the checkbox.
|
Description: The sample SQL fetches the column id from emp table and based on the value returns the appropriate number. |
|
|
Case 1 – convert to DECODE: The option convertCaseToDecode is set to true, which is the default value. In this case the CASE statement is converted to DECODE function in Oracle . |
|
| SOURCE SQL | CONVERTED SQL |
|
SELECT |
SELECT DECODE(id ,1
,'ONE',2 ,'TWO',3 ,'THREE',4 ,'FOUR',5 ,'FIVE','SIX')
|
|
Case 2 - convert to CASE: The option convertCaseToDecode is set to false. In this case the CASE statement is converted to CASE statement in Oracle . |
|
|
SELECT |
SELECT |
SwisSQL Console by default converts all table
columns which do not specify either 'NULL' or 'NOT NULL' constraint as
having NULL constraint, which is the default constraint in all
databases. In Sybase alone when 'NULL' or 'NOT NULL' constraint is not
specified the constraint is by default taken as 'NOT NULL'. For this
case Console allows user to specify whether the table should be
converted with NOT NULL constraint or with NULL constraint. When the
option SybaseNotNullConstraint is set to true columns
are converted with NOT NULL constraint in Oracle and SQL Server. When
the option SybaseNotNullConstraint is set to false
columns are converted with NULL constraint in Oracle and SQL Server.
In the "Conversion
settings" dialog select the check box "Set NOT NULL
constraint for table columns" to set the value
to true. To set the value to false unselect the checkbox.
|
Description: The sample SQL creates
employee table with empno and name as
columns without specifying the NULL or NOT NULL constraint
in Sybase |
|
|
Case 1 - column has NOT NULL constraint: The option SybaseNotNullConstraint is set to true. In this case the table is converted with NOT NULL constraint when constraint is not specified. |
|
| SOURCE SQL | CONVERTED SQL |
|
CREATE TABLE employee |
CREATE TABLE employee
|
|
Case 2 - column has NULL constraint: The option SybaseNotNullConstraint is set to false which is the default value. In this case the table is converted without NOT NULL constraint when constraint is not specified. |
|
|
CREATE TABLE employee |
CREATE TABLE employee |
SwisSQL Console by default converts all the ANSI
Join SQL queries to THETA joins in Oracle. It is possible to customize
the conversion to generate ANSI Join queries through configuration. For
this the configuration option ConvertToANSIJoinInOracle present
in the file SQLOneConsoleOptions.conf under the directory <InstallDir>/SwisSQL/Console5.5/conf
is to be used. The option is by default set to false, in which
case the ANSI join SQL queries will be converted to THETA convention.
If the option is set to true then the ANSI join SQL queries
will be converted to Oracle ANSI Joins.
In the "Conversion
settings" dialog select the check box "Convert ANSI
join to Oracle theta join" to convert the ANSI join to Oracle theta
join. To retain the ANSI join in Oracle unselect the checkbox.
|
Description: The sample SQL fetches the employee number, name, salary and department name whose salary is greater than the value in salarybound column of employee table and also does a left outer join to list all the employees who are either associated to a Department or not. |
|
|
Case 1 - Convert to THETA Join: The option ConvertToANSIJoinInOracle is set to false, which is the default value. In this case the SQL queries are converted to THETA Joins |
|
| SOURCE SQL | CONVERTED SQL |
|
SELECT
e.empno, e.name, e.deptno,
e.deptname FROM employee e LEFT OUTER JOIN Dept d ON e.deptno =
d.deptno WHERE e.salary >
e.salaryBound |
SELECT
|
|
Case 2 - Convert to ANSI Join:The option ConvertToANSIJoinInOracle is set to true. In this case the SQL queries are converted to ANSI Joins. |
|
|
SELECT e.empno, e.name, e.deptno, e.deptname FROM employee e LEFT OUTER JOIN Dept d ON e.deptno = d.deptno WHERE e.salary > e.salaryBound ORDER BY empno; |
SELECT e.empno, e.name, e.deptno, e.deptname FROM employee e LEFT OUTER JOIN Dept d ON e.deptno = d.deptno WHERE e.salary > e.salaryBound ORDER BY empno; |
SwisSQL Console by default converts all the THETA
join SQL queries in Oracle to ANSI join in SQL Server. It is possible
to customize the conversion to generate THETA Join queries through
configuration. The configuration option ConvertToThetaJoinInTSQL
present in the file SQLOneConsoleOptions.conf under the
directory <InstallDir>/SwisSQL/Console5.5/conf
is to be used. The option is by default set to false, in which
case the SQL queries will be converted to ANSI convention. If the
option is set to true then the SQL queries will be converted to
SQL Server THETA Joins.
In the "Conversion
settings" dialog select the check box "Convert Oracle theta
join to SQL Server theta join" to convert the Oracle theta join to SQL
Server theta join. To convert the Oracle theta join to ANSI join
unselect the checkbox.
|
Description: The sample SQL fetches the employee number, name, salary and department name whose salary is greater than the value in salarybound column of employee table and also does a left outer join to list all the employees who are either associated to a Department or not. |
|
|
Case 1 - Convert to ANSI Join: The option ConvertToThetaJoinInTSQL is by default set to false, in which case the SQL queries will be converted to ANSI convention in SQL Server. |
|
| SOURCE SQL | CONVERTED SQL |
|
SELECT e.empno, e.name, e.deptno, e.deptname FROM employee e, dept d WHERE e.salary > e.salaryBound AND e.deptno = d.deptno (+) ORDER BY empno |
SELECT e.empno, e.name,e.deptno, e.deptname FROM employee e LEFT OUTER JOIN Dept d ON e.deptno = d.deptno WHERE e.salary > e.salaryBound ORDER BY empno;
|
|
Case 2 - Convert to THETA Join:When the option ConvertToThetaJoinInTSQL is set to true, then the SQL queries are converted to Microsoft THETA Joins |
|
|
SELECT e.empno, e.name, e.deptno, e.deptname FROM employee e, dept d WHERE e.salary > e.salaryBound AND e.deptno = d.deptno (+) ORDER BY empno |
SELECT e.empno, e.name, e.deptno, e.deptname FROM employee e, dept d WHERE e.salary > e.salaryBound AND e.deptno *= d.deptno ORDER BY empno; |
SwisSQL Console by default indents all the converted SQL. This
option
can be customized by setting IndentConvertedSQL option in the
file SQLOneConsoleOptions.conf under the directory <InstallDir>/SwisSQL/Console5.5/conf
as true to indent the converted SQL and false to
convert the SQL without indentation.
In the "Conversion
settings" dialog select the check box "Indent the
converted SQL statement" to set the value
to true. To set the value to false unselect the checkbox.
SwisSQL Console by default converts the qualified object names
of Oracle
as is i.e. the object names of the format schema_name.object_name is
left as is. It is possible to customize the conversion to the format
schema_name.schema_name_object_name where the object name modified to
the form schema_name_object_name. This option can be customized by
setting RenameTableNameAsSchemaName_TableName option in the
file SQLOneConsoleOptions.conf under the directory <InstallDir>/SwisSQL/Console5.5/conf
as true to modify the object name and false to
leave the object name as is. This option is specific to Oracle to
Netezza SQL conversion.
In the "Conversion
settings" dialog select the check box "Rename table
name to schemaname_tablename" to set the value
to true. To set the value to false unselect the checkbox.
SwisSQL Console by default changes the case of the quoted
identifiers to
lowercase. It is possible to customize this conversion to change
the case to uppercase. This option can be customized by setting ConvertQuotedIdentifiersToUppercase
option in the file SQLOneConsoleOptions.conf under the
directory <InstallDir>/SwisSQL/Console5.5/conf
as true to change the case to uppercase and false
to change the case to lowercase.
In the "Conversion
settings" dialog select the check box "Convert the
quoted identifiers to upper case" to set the value
to true. To set the value to false unselect the checkbox.
The default target database to which the SQLs are to be
converted can be configured in the SwisSQL Console GUI. To change the
default target database access the menu item "Settings -> Select
target database" and select the check box of the target database you
wish to set as the default target database.
SwisSQL Console provides an option to convert Oracle TO_DATE
without
the
format argument as CAST AS TIMESTAMP or CAST AS DATE function to
Teradata. For this the checkbox "Convert Oracle TO_DATE function to
CAST AS TIMESTAMP function"
is to be used.
When this option is set to true by
selecting the checkbox, the TO_DATE
function is converted to
CAST function with TIMESTAMP(0) format in Teradata. When the option is
set to false, the TO_DATE
function is converted to the default CAST
function with DATE format.
| Case 1 :- Checkbox "Convert Oracle TO_DATE function to CAST AS TIMESTAMP function" is checked | |
| SOURCE SQL | CONVERTED SQL |
| SELECT TO_DATE('2003/07/09') FROM dual | SELECT CAST('2003/07/09' AS TIMESTAMP) |
| Case 2 :- Checkbox "Convert Oracle TO_DATE function to CAST AS TIMESTAMP function" is unchecked | |
| SOURCE SQL | CONVERTED SQL |
| SELECT TO_DATE('2003/07/09') FROM dual | SELECT CAST('2003/07/09' AS DATE) |
SwisSQL Console provides the option to add CASESPECIFIC clause
/ attribute
to CAST AS CHAR function while converting to Teradata. For this the
checkbox "Add CASESPECIFIC clause to CAST AS CHAR function"
can be used.
When this option is set to true by
selecting the checkbox the attribute
CASESPECIFIC is added to
the converted CAST function.
| Case 1 :- Checkbox "Add CASESPECIFIC clause to CAST AS CHAR function" is checked. | |
| SOURCE SQL | CONVERTED SQL |
| SELECT TO_CHAR('2003') FROM dual | SELECT CAST('2003' AS VARCHAR (50) CASESPECIFIC) |
| Case 2 :- Checkbox "Add CASESPECIFIC clause to CAST AS CHAR function" is unchecked. | |
| SOURCE SQL | CONVERTED SQL |
| SELECT TO_CHAR('2003') FROM dual | SELECT CAST('2003' AS VARCHAR (50)) |
SwisSQL Console provides the option to convert Oracle's
TRUNC(DATE)
function to CAST AS DATE function in Teradata. This enables the
Teradata optimizer to use Partition Elimination. For this the checkbox
"Convert Oracle TRUNC (DATE) function to CAST AS DATE function"
can be used.
When this option is set to true by
selecing the checkbox the function
is converted to CAST AS DATE. When this option is set to false the
function is converted as Teradata's TRUNC UDF.
| Case 1 :- Checkbox "Convert Oracle TRUNC (DATE) function to CAST AS DATE function" is checked | |
| SOURCE SQL | CONVERTED SQL |
| SELECT TRUNC(TO_DATE('22-AUG-03'), 'DD') FROM dual | SELECT CAST(CAST('22-AUG-03' AS TIMESTAMP) AS DATE) |
| Case 2 :- Checkbox "Convert Oracle TRUNC (DATE) function to CAST AS DATE function" is unchecked | |
| SOURCE SQL | CONVERTED SQL |
| SELECT TRUNC(TO_DATE('22-AUG-03'), 'DD') FROM dual | SELECT TRUNC(CAST('22-AUG-03' AS TIMESTAMP), 'DD') |
SwisSQL Console provides the following options to convert Oracle temporary table to Teradata. Any one of these options can be selected from the Combobox "Convert Oracle Temporary table to :"
| Oracle temporary table is converted to global temporary table in Teradata | |
| SOURCE SQL | CONVERTED SQL |
| CREATE GLOBAL TEMPORARY TABLE T_V_Table1 (department_number ) ON COMMIT PRESERVE ROWS PARALLEL AS SELECT deptno dep artment_number FROM emp | CREATE GLOBAL TEMPORARY
TABLE T_V_Table1 , NO LOG
(department_number ) AS (SELECT deptno department_number FROM emp )<
span style="color: blue;">WITH NO DATA ON COMMIT PRESERVE ROWS INSERT INTO T_V_Table1 ( SELECT deptno department_number FROM emp ) |
| Oracle temporary table is converted to volatile table in Teradata | |
| SOURCE SQL | CONVERTED SQL |
| CREATE GLOBAL TEMPORARY TABLE T_V_Table1 (department_n umber ) ON COMMIT PRESERVE ROWS PARALLEL AS SELECT deptno dep artment_number FROM emp | CREATE VOLATILE TABLE
T_V_Table1 , NO LOG
(department_number ) AS (SELECT deptno department_number FROM emp )WITH
DATA ON COMMIT PRESERVE ROWS |
| Oracle temporary table is converted to permanent table in Teradata | |
| SOURCE SQL | CONVERTED SQL |
| CREATE GLOBAL TEMPORARY TABLE T_V_Table1 (department_n umber ) ON COMMIT PRESERVE ROWS PARALLEL AS SELECT deptno dep artment_number FROM emp | CREATE TABLE
T_V_Table1 (department_number ) AS
(SELECT deptno department_number FROM emp )WITH
DATA |



| |
|
|||
|
|
||||
| © 2011 ZOHO Corporation | ||||