This tutorial shows you how to migrate a Sybase database to Oracle Database 11g using Oracle SQL Developer.
Approximately 45 minutes
What Is SQL Developer?
Oracle SQL Developer is a free graphical tool that enhances productivity and simplifies database development tasks. Using Oracle SQL Developer, you can browse database objects, run SQL statements, edit and debug PL/SQL statements and run reports, whether provided or created.
Sybase Migration Overview
Using Oracle SQL Developer, you can quickly migrate your third-party database to Oracle.
There are four main steps in the database migration process:
Capture the Source Database | The first step is to capture a "snapshot" of the
Sybase database. This can be done in two ways.
Using SQL Developers Offline Capture feature, the pubs2 sample database
has been extracted into offline data files. The Sybase15.ocp file generated
by the Capture tool contains the database schema information for the
Sybase pubs2 database. Oracle SQL Developer uses this file as the basis
for building a representation of the structure of the source Sybase
database. This structure is called the Captured Model. |
Convert the Captured Database | Oracle SQL Developer uses the Captured Model to convert the captured objects to Oracle-format objects, building up a representation of the structure of the destination database. This structure is called the Converted Model. |
Generate the Oracle Database | Oracle SQL Developer generates DDL statements to create the new Oracle database, based upon the Converted Model objects. Running the DDL statements will result in the creation of the objects in the Oracle database. |
Migrate the Data | The last step in the process is to migrate the data. You
can do this in one of two ways.
|
Before starting this tutorial, you should:
. |
Install the Oracle Database 10g or later, or Oracle Database XE |
---|---|
. |
Download and unzip Oracle SQL Developer here. |
. |
Download and unzip the |
To create a new database user, perform the following steps:
Note: If you already have a system_orcl connection and a mwrep user, you can skip these steps.
. |
If you installed the SQL Developer icon on your desktop, click the icon to start
your SQL Developer session. If you do not have the icon located on your desktop,
find the executable file (either named "sqldeveloper.exe" on Windows
|
---|---|
. |
Select View > Connections.
|
. |
In the Connections tab, right-click Connections and select New Connection. A New / Select Database Connection window will appear.
|
. |
The New / Select Database Connection dialog opens. Enter the connection details as follows and click Test. Connection Name: system_orcl
|
. |
Check for the status of the connection on the left-bottom side (above the Help button). It should read Success. To save the connection, click Save. Then click Connect. Close the window.
|
. |
The connection is saved and you can see it listed under Connections in the Connections navigator.
|
. |
Expand system_orcl. Note: When a connection is opened, a SQL Worksheet is opened automatically. The SQL Worksheet allows you to execute SQL against the connection you just created.
|
. |
Enter the following code in the SQL Worksheet to create a user for the migration repository CREATE USER MWREP
|
. |
Click Run Script .
|
. |
The mwrep user was created successfully.
|
To convert the Sybase database to Oracle, you need to create a repository to store the required repository tables and PL/SQL packages. To do this, perform the following steps:
Note: If you already have a mwrep_orcl connection and a migration repository for it, you can skip these steps.
. |
Before you create the repository, you need to create a connection to the mwrep user. In the Connections tab, right-click Connections and select New Connection. A New / Select Database Connection window will appear. Note: If this tab is not visible, select View > Connections.
|
---|---|
. |
The New / Select Database Connection dialog opens. Enter the connection details as follows and click Test. Connection Name: mwrep_orcl
|
. |
Check for the status of the connection on the left-bottom side (above the Help button). It should read Success. To save the connection, click Save. Then click Connect. Close the window.
|
. |
The connection is saved and you can see it listed under Connections in the Connections tab.
|
. |
Right-click the mwrep_orcl connection and select Migration Repository > Associate Migration Repository.
|
. |
A progress window appears. Click OK.
|
The procedure for creating the Sybase database scripts has been completed for you and the files are available in the zip file provided in the prerequisites.
To load the captured Sybase database scripts into Oracle SQL Developer, perform the following steps:
. |
Select Tools > Migration > Migrate.
|
---|---|
. |
The migration wizard appears and it will walk you through the steps to convert third party databases to Oracle.
|
. |
In step 2, you need to select a connection for the migration repository. Select the mwrep_orcl connection, and click Next.
|
. |
In step 3, you need to provide the Project details. A Project is a container for the migration entities. Provide a Name to the project, and specify the Output Directory. Click Next.
|
. |
In step 4, you need to provide the Source Database details. Select the mode as Offline. Click Choose to select the Offline Capture Source file.
|
. |
Select sybase15.ocp file from the files downloaded onto your working directory as part of the prerequisites and click Open.
|
. |
Click Next.
|
. |
In step 5, you need to select the database for definition capture. Select the pubs2 database and check Proceed to Summary Page. Click Next.
|
. |
Click Finish.
|
. |
The Database Migration actions are completed successfully. A message dialog box appears. Click OK .
|
It is important to review the conversion preferences at this point. To do so, perform the following steps:
. |
Select Tools > Preferences.
|
---|---|
. |
Expand Migration and select Identifier Options. Make sure "Is Quoted Identifier On" is not selected. This is because the Sybase pubs2 database recognizes double quotes as String literals. If this is set incorrectly it can cause the conversion failure of procedures, triggers and views. Click OK.
|
To convert the captured Sybase database scripts into Oracle SQL Developer, perform the following steps:
. |
In the Migration Projects tab, select and right-click the captured database. Click Convert.
|
---|---|
. |
In the Migration Wizard, click Next
|
. |
You can specify the conversion options. You can add a new rule. Check Proceed to Summary Page. Click Next.
|
. |
Click Finish.
|
. |
The Database Migration actions are completed successfully. A message dialog box appears. Click OK.
|
. |
In Migration Projects tab, expand Converted Database Objects. Expand pubs2 > dbo_pubs2 > Procedures. Here you will find a procedure "expectedToFail" that has a red "x" icon against it. This is a failed procedure.
|
. |
Select dbo_pubs2 tab. Select Conversion Issues. This will display a report of "Translation limitation" and "Errors".
|
An error represents the failure to convert an object. This generally only affects objects defined in T-SQL (Procedures, Triggers, Functions, and Views). These objects are available in the Converted Model after the conversion, but they remain defined in Sybase T-SQL and have not been converted to Oracle PL/SQL.
Generally an object fails to convert because a part of the T-SQL is not recognized. Once this part of the T-SQL is identified, it can be worked around so that the majority of the translation can be performed automatically. Leaving only a small section of T-SQL to manually translate.
In this tutorial, the sample database has been seeded with one procedure that fails to convert. The following steps outline how to go about identifying the issue and complete its conversion. The steps used here are the same for any type of conversion failure.
To resolve the errors, perform the following steps:
. |
Select the Converted Database Objects in the Migration Projects and expand dbo_pubs2.
|
---|---|
. |
Expand Procedures and select expectedToFail.
|
. |
Copy the contents of the expectedToFail procedure.
|
. |
Select Tools > Migration > Translation Scratch Editor.
|
. |
Paste the copied text from the expectedToFail procedure in the left side text box.
|
. |
Click the drop-down list and select Sybase T-SQL To PL/SQL.
|
. |
Also, select the project model from the drop-down list.
|
. |
Click Translate .
|
. |
You get an error as expected. Click OK
|
. |
Commenting out statements until the procedure translates will help you identify the problematic statement. In this case there is a new line between the bang and equals -"where lower(title) != @title". A quick solution would be to remove the space, but a more generic approach for all issues would be to comment out the clause with a TODO comment. Then manually replace it once in Oracle. Now, fix the bug and click Translate again. You can notice that the code has been successfully translated into PL/SQL on the right side textbox.
|
. | Select the contents of the corrected expectedToFail
procedure from the left side text box and copy it.
|
. | In the Migration Projects navigator, click Captured
Database Objects > pubs2 > dbo > Procedures.
|
. |
Select the expectedToFail procedure. Paste the copied content over the existing expectedToFail procedure.
|
. |
Click Save .
|
. |
Right-click expectedToFail procedure in the left-side navigation bar under Procedures. Select Reconvert.
|
. |
Click OK on the dialog box. Note: The procedure "expectedToFail" in the Converted Database Objects will be shown as erroneous even after conversion. This is a known issue in Oracle SQL Developer 3.0 |
To generate target database, perform the following steps:
. |
In the Migration Projects tab, right-click Converted Database Objects. Select Generate Target.
|
---|---|
. |
In the Migration Wizard, click Next
|
. |
This step provides you the Target Database details. Select the mode as Offline. You can select to drop the target objects here. Note down the Generated Script Directory location. Check Proceed to Summary Page. Click Next.
|
. |
Expand Generate Script. Click Finish.
|
. |
The Database Migration actions are completed successfully. A message dialog box appears. Click OK.
|
To generate the SQL script with DDL statements that will be executed to create the objects in an Oracle Database, perform the following steps:
. |
Select the Project tab. The SQL from the script appears. Select system_orcl from the drop-down list on the right.
|
---|---|
. |
Click Run Script .
|
. |
Now that your scripts have run successfully, you can create a connection for the dbo_pubs2 user. Right-click Connection and select New Connection.
|
. |
The New / Select Database Connection dialog opens. Enter the connection details as follows and click Test. Connection Name: dbo_pubs2_orcl
|
. |
Check for the status of the connection on the left-bottom side (above the Help button). It should read Success. To save the connection, click Connect. Close the window.
|
. |
Expand dbo_pubs2_orcl.
|
. |
Expand Tables.
|
. |
The database tables that were converted to Oracle are listed. Select AUTHORS.
|
. |
Select Data tab. Notice that currently there is no data in the table. You will migrate the data later in this OBE.
|
A date format mask can be specified in the preferences so that the Offline Data Move scripts (in particular, the Oracle SQL*Loader control files) can reference the correct format. To do so, perform the following steps:
. |
Select Tool > Preferences.
|
---|---|
. |
Expand Migration and select Data Move Options.
|
. |
Make sure the Date Mask format matches the following Mon dd yyyy HH:mi:ssAM
|
. |
Make sure the Timestamp Mask matches the following. Mon dd yyyy HH:mi:ss:ff3AM Click OK.
|
To move data to the target database, perform the following steps:
. |
In the Migration Projects tab, right-click Converted Database Objects. Select Move Data.
|
---|---|
. |
In the Migration Wizard, click Next
|
. |
This step provides details about the Data Move . Select Offline. Note down the location of Data Move Script Directory. Select Offline. Click Next.
|
. |
Expand Move Data. Click Finish.
|
. |
The Database Migration actions are completed successfully. A message dialog box appears. Click OK.
|
The data has already been generated from Sybase.
To import the data using the scripts provided, perform the following steps:
. |
Open a terminal and execute the following commands: <prompt> cd <location of the unzipped files\files\DataMove\sybase_obe\2011-02-01_09-25-25> <prompt> oracle_ctl.bat <username> <password>@<connection> Note: oracle_ctl is a bat file that contains statements to load the data. It uses sqlldr to load the data.
|
---|---|
. |
The command executes successfully.
|
. |
Switch to Oracle SQL Developer and click Refresh . .
|
. |
The data for the table has been loaded successfully.
|
To have an overview of the migration and to know how much of the migration has been completed automatically, perform the following steps. This will generate a spreadsheet that provides a summary of the databases that have been migrated from the repository.
. |
In the Migration Projects tab, right-click the project. Select Generate Estimation Plan.
|
---|---|
. |
Select the location where you would like to save the report. Click Create.
|
. |
The Excel sheet is displayed. It gives a summary of the various objects within the database. To have a detailed view of the objects, click individual object type sheets within the Excel sheet.
|
Depending on the complexity of the database being migrated, a large part of the migration project could be testing.
Currently Oracle does not provide many tools that can automatically validate a migrated database for you. This phase of the migration should be planned and taken into account before the migration begins.
The following should be part of your project plan
As a part of the SQL Developer 3.0, there is a simple way to migrate 3rd party databases. This is called "Copy to Oracle". This is a replacement of the Quick Migrate functionality in the previous releases.
Using this feature, you can copy tables quickly and easily from a third party database to an oracle connection.
Click here to learn more about "Copy to Oracle" feature of SQL Developer 3.0.
In this tutorial, you have learned how to:
About Oracle |Oracle and Sun | | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Your Privacy Rights | |