ORACLE TO SYB<strong>ASE</strong> <strong>ASE</strong> MIGRATION GUIDERev.1.3etc, and au<strong>to</strong>matically convert the <strong>Oracle</strong> datatypes in<strong>to</strong> their <strong>ASE</strong> equivalent, this is the fastest and most efficientschema migration method available.Section 4.2 describes how <strong>to</strong> use PowerDesigner for this purpose.Section 4.3 describes a possible approach <strong>to</strong> reverse-engineer the schema without PowerDesigner.4.2 Using <strong>Sybase</strong> PowerDesigner for database schema migration<strong>Sybase</strong> PowerDesigner is arguably the most advanced data modeling <strong>to</strong>ol in the market. It is a stand-alone <strong>to</strong>ol, runningon Windows. PowerDesigner supports over 30 database types, including <strong>Oracle</strong> and <strong>Sybase</strong> <strong>ASE</strong>.For more information on PowerDesigner, see http://www.sybase.com/powerdesigner .With PowerDesigner it is relatively straightforward <strong>to</strong> reverse-engineer most of the <strong>Oracle</strong> schema and convert it <strong>to</strong><strong>Sybase</strong> <strong>ASE</strong>. The central concept used by PowerDesigner is the PowerDesigner Physical Data Model (PDM). This is adatabase-independent model which can be converted <strong>to</strong> the SQL DDL dialect of each supported database.4.2.1 PowerDesigner schema conversion stepsFor detailed, step-by-step instructions on how <strong>to</strong> use PowerDesigner <strong>to</strong> convert the database schema from <strong>Oracle</strong> <strong>to</strong><strong>Sybase</strong> <strong>ASE</strong>, see the document “Migrating an <strong>Oracle</strong> Database <strong>to</strong> SAP <strong>Sybase</strong> <strong>ASE</strong> with PowerDesigner and ECDA (A Step-By-Step Practical <strong>Guide</strong>)” at http://www.sybase.com/support/techdocs/migration.Once the schema is reverse-engineered, run the completed DDL script in <strong>Sybase</strong> <strong>ASE</strong> and check for any errors.Note that some aspects of schema migration cannot be handled by PowerDesigner and will have <strong>to</strong> be handleddifferently. These aspects are described in section 4.4.4.3 Reverse-engineering the <strong>Oracle</strong> schema without <strong>Sybase</strong> PowerDesignerWithout using <strong>Sybase</strong> PowerDesigner, reverse-engineering the schema can be done in a number of ways:Use the <strong>Oracle</strong> SQL*Plus DESC command on all database objects, and process the output so that they arevalid DDL statements. This is likely <strong>to</strong> require significant manual script coding.Use the <strong>Oracle</strong> DBMS_METADATA package <strong>to</strong> extract DDL for the <strong>Oracle</strong> objects. This involves SQLstatements such as the following (for <strong>Oracle</strong> table 'MY_TABLE', in schema/user 'SALESAPP'). Note thatthese are only examples, this is not a complete list of all statement required <strong>to</strong> perform full reverse-engineering:SELECT DBMS_METADATA.GET_DDL('TABLE', 'MY_TABLE', 'SALESAPP') FROM DUAL;SELECT DBMS_METADATA.GET_DEPENDENT_DDL('INDEX', 'MY_TABLE', 'SALESAPP') FROMDUAL;SELECT DBMS_METADATA.GET_GRANTED_DDL('OBJECT_GRANT', 'SALESAPP') FROM DUAL;Use <strong>Oracle</strong> SQL Developer (a free Java-based <strong>to</strong>ol, downloadable from oracle.com). This uses theDBMS_METADATA package (see previous bullet).Use TOAD (a low-cost <strong>to</strong>ol, commonly used in many <strong>Oracle</strong> environments) <strong>to</strong> extract the object definitions,and then manually convert the <strong>Oracle</strong> datatypes in<strong>to</strong> their <strong>ASE</strong> equivalent. This could be cumbersome whenlarge numbers of tables are involved.Once the <strong>Oracle</strong> schema has been reverse-engineered, the <strong>Oracle</strong> DDL needs <strong>to</strong> be converted <strong>to</strong> <strong>Sybase</strong> <strong>ASE</strong> syntax,including conversion from the <strong>Oracle</strong> datatypes <strong>to</strong> <strong>Sybase</strong> <strong>ASE</strong> datatypes. Section 4.7 describes the mapping from<strong>Oracle</strong> datatypes <strong>to</strong> <strong>Sybase</strong> <strong>ASE</strong>.In addition, some aspects of the <strong>Oracle</strong> schema require special attention; see section 4.4.4.4 Special cases in schema migrationThe following schema aspects require special attention:Database Schema <strong>Migration</strong> 18
ORACLE TO SYB<strong>ASE</strong> <strong>ASE</strong> MIGRATION GUIDERev.1.3<strong>Oracle</strong> allows more columns per table than <strong>Sybase</strong> <strong>ASE</strong> (the limit depends on the <strong>ASE</strong> server's page size andon the table's lock scheme). If the limit in <strong>Sybase</strong> <strong>ASE</strong> is exceeded, an error will be raised when trying <strong>to</strong> createthe table. If this occurs, either the <strong>ASE</strong> server's page size will need <strong>to</strong> be increased, or the table needs <strong>to</strong> besplit vertically in<strong>to</strong> multiple tables and all queries referencing the table likely have <strong>to</strong> be modified accordinglyIf the length of a column exceeds the maximum allowed length in <strong>Sybase</strong> <strong>ASE</strong> (the limit depends on the <strong>ASE</strong>server's pagesize and on the table's lock scheme), such columns will have <strong>to</strong> be split in<strong>to</strong> multiple columns andplaced in additional tables. All queries referencing the column likely have <strong>to</strong> be modified accordingly.PowerDesigner converts the <strong>Oracle</strong> BFILE datatype <strong>to</strong> the <strong>Sybase</strong> <strong>ASE</strong> image datatype. Since BFILE is adatatype used <strong>to</strong> s<strong>to</strong>re a loca<strong>to</strong>r (link) <strong>to</strong> an external binary file s<strong>to</strong>red outside of the database, this is notfunctionally equivalent so application changes may be required. If a different <strong>ASE</strong> datatype is required, forexample, <strong>to</strong> hold the name of an externally s<strong>to</strong>red file, change it manually.PowerDesigner 15.x cannot au<strong>to</strong>matically convert the <strong>Oracle</strong> timestamp datatype <strong>to</strong> bigdatetime in<strong>ASE</strong>, so this needs <strong>to</strong> be done manually. PowerDesigner 16.0 (release expected in August 2011) does not havethis limitation and will perform the conversion au<strong>to</strong>matically. PowerDesigner 15.x cannot reverse-engineer <strong>Oracle</strong> users or security details (permissions). PowerDesigner 16.0(release expected in August 2011) does not have this limitation and is capable of handling these aspects.Since the SQL reserved words are different between <strong>Oracle</strong> and <strong>Sybase</strong> <strong>ASE</strong>, before attempting a databaseschema migration, all <strong>Oracle</strong> objects need <strong>to</strong> be checked against the <strong>Sybase</strong> <strong>ASE</strong> reserved words. Any <strong>Oracle</strong>identifiers that are also <strong>Sybase</strong> <strong>ASE</strong> reserved words, need <strong>to</strong> be changed first. For a complete list of reservedwords in <strong>Sybase</strong> <strong>ASE</strong>, see “Adaptive Server Enterprise->Reference Manual: Building Blocks->Reserved Words”.Also see section 4.8 for queries that can be used <strong>to</strong> search for the occurrence of keywords in the <strong>Oracle</strong>database.The mapping of <strong>Oracle</strong> user-defined datatypes <strong>to</strong> <strong>ASE</strong> can be difficult and may require extensive manualintervention. The key <strong>to</strong> user-defined datatype migration is <strong>to</strong> fully understand the underlying base datatype.Note that user-defined datatypes can be nested. For <strong>Oracle</strong>, user-defined datatypes is an add-on option <strong>to</strong> thedatabase and is not widely used.4.5 Mapping the <strong>Oracle</strong> schema <strong>to</strong> <strong>Sybase</strong> <strong>ASE</strong> databases<strong>Sybase</strong> <strong>ASE</strong> does not have an identical interpretation of the concept of "schema" as the "<strong>Oracle</strong> schema". Whenmigrating an <strong>Oracle</strong> schema <strong>to</strong> <strong>Sybase</strong> <strong>ASE</strong>, there are two basic options <strong>to</strong> map the <strong>Oracle</strong> schema <strong>to</strong> <strong>Sybase</strong> <strong>ASE</strong>.For the sake of example, let's assume there are two <strong>Oracle</strong> users john and bill who own an <strong>Oracle</strong> schema, and eachschema has a table named salesdetails.The options are:Perhaps the most straightforward way <strong>to</strong> migrate, is <strong>to</strong> map each <strong>Oracle</strong> schema <strong>to</strong> a separate <strong>ASE</strong> database,where each database is owned ('dbo') by the corresponding user. This would result in two <strong>ASE</strong> databasesnamed john_db and bill_db (different names may of course be chosen), owned by <strong>ASE</strong> logins john andbill respectively; each database has table named salesdetails, owned by the dbo database user (the fulltable name would be dbo.salesdetails).However, this results in as many <strong>ASE</strong> databases as there are users owning an <strong>Oracle</strong> schema, of which theremight be many. While an <strong>ASE</strong> server can hold up <strong>to</strong> 32786 databases, it is highly impractical from a DBAperspective <strong>to</strong> have more than 20-50 databases.Map all <strong>Oracle</strong> schemas <strong>to</strong> a single <strong>ASE</strong> database with a multi-tenancy model. This means that the <strong>ASE</strong>database user (which is linked <strong>to</strong> the <strong>ASE</strong> server login, which is the equivalent of an <strong>Oracle</strong> user) is used withinthe database <strong>to</strong> identify each object's owner. This will result in a more manageable <strong>ASE</strong> system since there willbe less <strong>ASE</strong> databases.In this case, the example would result in a single <strong>ASE</strong> database, let's say sales_db, in which <strong>ASE</strong> logins johnDatabase Schema <strong>Migration</strong> 19