SlideShare a Scribd company logo
1 of 50
Download to read offline
2086/Migrating SQL Server 2005
    Applications to Oracle
          Mike Gangler
          Ithaka / JStor
            Session #
              2086
Speaker and Company Information
• Database Specialist with JSTOR – www.jstor.org
• 20+ Years DBA experience
• Presented Collaborate in ’07, SEMOP, Regional user Groups
  and at many IOUG-Alive events
• Experience with FOCUS, IMS DB/DC, DB2, Sybase, and
  MSSQL 6.5 databases prior to assignment.
• JSTOR - is a not-for-profit organization dedicated to helping the
  scholarly community discover, use, and build upon a wide range
  of intellectual content in a trusted digital archive. We collaborate
  with organizations that benefit the scholarly community.
Agenda
•   Introduction

•   Overview of Problem

•   Basic and Fundamental Differences

•   Database Locking
•
•   Data Objects

•   Data Types

•   Data Access – DML and Examples
Introduction
•   This session will describe the lessons learned during the process of
    converting an MSSQL database application to Oracle.

•   Session targeted towards Oracle DBA’s with little or no MSSQL
    experience.

•   JSTOR purchased a 3rd party product that was using primarily MSSQL.

•   Agreement was that JSTOR would convert MSSQL patches and coding
    to Oracle (If and when needed).

•   Project started in 2006 and we launched the new product in April 2008.

•   Using Oracle 10G release 2 and Grid Control on Sun Solaris X86-64
    machines

•   3rd Party using SQL Server 2005
Overview of Problem
• JSTOR Is primarily a Oracle Shop

• 3rd Party is primarily a MSSQL Shop

• Coding was supposed to be “Database Agnostic”

• Limited assistance from 3rd Party

• Limited experience with MSSQL

• 2 development centers – Santa Clara and Ann Arbor
   – code control
   – version control
   – little or no communication

• 3 – 5 patches a day
Basic and Fundamental Differences

• Database, Instance and Storage Architecture
  –   Terminology
  –   Characteristic Differences
  –   Comparison of Core Objects
  –   Storage Architecture
  –   Data Blocks, Extents and Segments
  –   Memory Address Space – Oracle
  –   Memory Address Space – MSSQL
  –   Process and Thread-based Architecture
  –   Background Processes
Basic and Fundamental Differences -
Database and Instance

• Terminology –
  – Oracle Instance = Memory and Processes related
    to a Database.
  – Oracle Database = Files containing application
    and system information
  – MSSQL Instance = set of binaries isolating the
    SQL Server database Engine Services.
     • Every Instance will have its own system database and
       separate Admin parms.
  – MSSQL Database = Oracle schema with a Master
    DB (System Tables).
Basic and Fundamental Differences –
Database and Instance
Characteristic            Oracle             SQL Server
Minimum Block Size        2KB                8KB

Maximum Block Size        16KB               8KB
Maximum Blocks Per File   4 Million blocks   2 Million Blocks

Maximum File Size         64Gb               16TB
Maximum # of Files        65K                32K

Maximum DB Size           4PB                1EB

Instances Per Server      Based on Server    50
                          Resources
Max # of tablespaces      65K                32K File Groups

Max log file size         64 Gb              32TB

Max # of tablespaces      65K                32K File Groups
Basic and Fundamental Differences –
Comparison of Core Objects
Oracle              SQL Server
Table               Table

Index               Index
View                View

Synonym             Synonym
Sequence            N/A

Procedure           Stored Procedure

Function            Function

Package             N/A

Streams             Service Broker Queue

XMLDB               XML Schema Collection

Object Type         Type
Basic and Fundamental Differences – Storage
Architecture

• Physical
  – Oracle Data file = MSSQL data file or Device
• Logical
  –   Oracle tablespace = MSSQL File Group
  –   Oracle Segment = MSSQL Heap/Index
  –   Oracle Extent = MSSQL Extent
  –   Oracle Blocks = MSSQL Pages
Basic and Fundamental Differences –Data
Blocks, Extents and segments

• Smallest unit of logical storage
   – Oracle = Block
   – MSSQL = Page
• Block size
   – Oracle is variable
   – MSSQL is fixed at 8kb
• Extent size
   – Oracle is variable
   – MSSQL are fixed at 64kb
Basic and Fundamental Differences –Memory
Address Space - Oracle
• Memory Allocation Concepts – Oracle

  – Oracle is static

  – Allocated at Startup

  – MSSQL is Dynamic

  – Variables set by administrator

  – ASSM introduced in Oracle 10g
Basic and Fundamental Differences –Memory
Address Space – MSSQL 2005
• Memory Allocation Concepts – MSSQL 2005

   – Allocations are constantly changed based on RDBMS needs and
     operating system needs (Self Tuning).

   – Allocation is dynamic at higher level (Memory pool, etc.) and lower
     level ( Buffer cache, procedure cache, etc.) components.

   – Very Few configurable parameters

   – Min server memory and max server memory settings

• Memory address range

   – Leveraging Address Windowing Extensions (AWE)
Basic and Fundamental Differences –Process
and Thread-based Architecture
•   Process is an independent piece of code with its own memory space

•   Thread is spawned by a process and works within the parents memory
    space

•   Advantages of using Threads:
     – Reduced overhead in context switching and reduction in overall
       memory requirements
     – Microsoft fibers are light-weight threads further reduces context
       switching overheads by running purely in user mode

•   Oracle uses processes in Unix and Threads in Windows

•   Both Oracle and SQL Server use threads and optionally fibers.
    Threads/fibers are scheduled onto a CPU by a user mode Scheduler
    (UMS)

•   Process/thread can be tied to processors in both Oracle (Windows) and
    SQL Server 2005 using CPU affinity feature.
Basic and Fundamental Differences –
Background Processes
Oracle       Oracle ID   SQL Server     required
Processes
Process      PMON        SQLOS          Mandatory
monitor
System       SMON        Database       Mandatory
Monitor                  Cleanups and
                         Shrinking
DB Writers   DBWn        Lazywriter     Mandatory


Checkpoint   CKPT        Database       Mandatory
Processes                Checkpoint


Recoverer    RECO        MS DTC         Optional


Logwriter    LGWR        Log Writer     Mandatory
Basic and Fundamental Differences –
Background Processes

 Oracle       Oracle ID   SQL Server required
 Processes
 Archive      ARCn        N/A         N/A


 Job Queue    Jnnn        SQL Agent   Mandatory
 Process
 Parallel     Pnnn        Worker      Optional
 Slave                    Threads
 processes
 Dispatcher   Dnnn        Networker   Mandatory
                          Threads

 Shared       Snnn        Worker      Mandatory
 Servers                  Threads
Database Locking
• MSSQL – Prior to SQLSERVER 2005
  – Select statements obtain shared locks on
    pages/rows.
     • Prevents other statements from obtaining an exclusive
       lock on those pages/rows.
     • All Update statements require exclusive lock.
     • These locks will lock all update transactions until the
       select commits or roll backs.
     • transactions are physically serialized whenever 1
       transaction selects the data and 1 changes.
• ORACLE –
  – Readers don’t block writers and writers don’t
    block readers.
Database Locking – Row Vs Page

• MSSQL
  – Prior to MSSQL 2005 no row level locking
  – Does page level locking, which blocks all rows on
    the page.
  – MSSQL2005 – does a form of row level locking.
  – MSSQL2005 – Escalates locks at row level to
    page level automatically.
• ORACLE
  – Row level locking
  – Only one row is locked when DML is changing the
    row.
Data Objects
Oracle                    SQL Server
Heap-Organized Table      Heap
Clustered Table           N/A
Partitioned Table         N/A
Nested Table              N/A
Temporary Table           Temporary Table
External Table            ** Linked Server Feature
Object Table              Table Variable
Indexed-Organized Table   Clustered Index
Data Objects - Table
• Heap is the default Form of data organization in a
  table, where data is stored in an unordered manner

• In Oracle, Index Organized Tables store data in a B-
  Tree structure in primary key order.

• SQL Server offers clustered indexes where data can
  be ordered by any column

• Oracle and MSSQL offer local and global temporary
  tables to store transient application data
Data Objects – Indexes (Diff)
Index Scheme            Oracle          MSSQL
B-tree Composite        Yes (32 Cols)   Yes (16 Cols)
B-Tree Reverse          Yes             No
B-Tree Key Compressed   Yes             No
B-Tree Function Based   Yes             No
B-Tree IOT              Yes             Yes (Clustered)
B-Tree Partition        Yes             No
Bitmap                  Yes             No
Bitmap Join             Yes             No
Data Objects – Views (Diff)
View Type          Oracle          MSSQL
Object Views       Yes             No
Indexed Views      No              Yes

 Updateable Views – Restrictions in MSSQL can be
 bypassed by defining a “INSTEAD OF” trigger on the
 view.
 INLINE Views – MSSQL use Derived tables and CTE
 (Common table Expressions)
Data Types – Character Based
Oracle Type   Oracle Size   SQL Type   SQL Size

Char          1 – 2000      Char       1 - 8000

NChar         1 – 2000      NChar      1 – 4000

Varchar       1 – 4000      Varchar    1 - 8000

NVarchar      1 – 4000      NVarchar   1 - 8000

Varchar2      1 – 4000      Varchar    1 - 8000

NVarchar2     1 – 4000      Nvarchar   1 - 8000

LONG          1 – 2Gb       Text       2GB


CLOB          4GB           Text       2GB

NCLOB         4GB           NText      2GB

BLOB          4GB           Image      2GB
Data Types – Numeric Data
     Oracle Type          SQL Type

     Number(19,0)         Bigint

     Int / Number(10,0)   int

     Smallint /           smallint
     Number(6,0)
     Number(3,0)          tinyint

     Number(p,0)          decimal

     Number(p,0)          Numeric(p,s)

     Float / Number(38)   Float

     Number(1)            Bit

     Number(19,4)         Money

     Number(10,4)         Small Money
Data Types – Other Types
  Oracle Type      SQL Type

  Date             datetime

  Date             Smalldatetime

  Timestamp        datetime

  RAW(n) / BLOB    Binary(n)

  RAW(n) / BLOB    VARBINARY(n)

  FLOAT            FLOAT

  REAL             FLOAT
Date Data Types
• MSSQL datetime accurate up to 3.33 Milliseconds.
• Oracle “date” is accurate up to 1 second.
• Oracle’s timestamp up to 1 Millisecond.
• MSSQL “smalldatetime” up to 1 Minute.
• If application requires sub second Date Precision use
  Oracle’s “timestamp”.
• MSSQL “timestamp” not related to “datetime”
   – MSSQL2005 – “timestamp” = SQL2000 –
      “rowversion.
   – It's a unique value which is changed every time
      the row is updated
Data Access – DML and Examples
MSSQL                            Oracle
GO                               Semi Colon (;)

Select sqrt(100)                 Select sqrt(100) from dual

Select ‘last Name’=lastname      Select lastname “Last Name”
from ….                          from …. Or
                                 Select lastname as ‘last name’
                                 from ….
Select lastname +’,’+firstname   Select lastname||’,’||firstname
from ….                          from …
Select top 5 from table          Select * from table where
                                 rownum <=5
Data Access – DML and examples
MSSQL                            Oracle
Left outer Join                  Where ta.col(+) = tb.col
Nullif(exp,exp)                  case
ISNULL(EXP,VAL)                  NVL(exp,val)

Select getdate()                 Select sysdate from dual
Case                             Case or decode
Select 3+5 (from not required)   Select 3+5 from dual
Create procedure                 Create or replace procedure
Sp_rename                        n/a – procedure to emulate the
                                 sp_rename function.
Select clause Differences
• MSSQL
  –   “TOP”
  –   “IDENTITYCOL”
  –   “ROWGUIDCOL”
  –   Column Alias – select c1 = ‘alias’ from t1
• ORACLE
  –   Select c1 from t1 where rownum < n
  –   Doesn’t support “identitycol”
  –   Doesn’t support “rowguidcol” (sys_guid)
  –   Column alias – select c1 “alias’ from t1
Update Statements
• MSSQL
  – Supports a “FROM” clause
  – MSSQL Example:
     • Update t1 set col1=0 from t1=a, t2=b where a.c2 = b.c2
• ORACLE
  – Doesn’t Support a “FROM” clause
  – Oracle Example:
     • Update t1 set col1=0 where col1 in (select col1 from t2
       where c3 = ‘USA’)
Delete Statements
• MSSQL
  – Supports a “FROM” clause
  – MSSQL Example:
     • Delete tableA from tableA a, tableB b where a.c1 = b.c1


• ORACLE
  – Doesn’t Support a “FROM” clause
  – Oracle Example:
     • Delete tableA a
     • Where exists (select * from tableB b where a.c1 = b.c1)
“Into” Clause
• MSSQL
  – Select * into t1 from t2
  – Insert * into t1 from t2
• ORACLE
  – Create table t1 as select * from t2
  – Insert into t1 as select * from t2
Global Tables Examples
• MSSQL
  Create table #a_temp_table (col1 INT, col2 char(1))


• Oracle
  Create global temporary table
  tt_a_temp_table (col1 number(6), col2 char(1))
  On commit reserve rows
Empty String Literals
• MSSQL – interprets empty string as a single
  blank space
• Oracle – interprets empty string as NULL
• MSSQL
  – Insert into table (c1, c2) values (‘foo’,’’)
  – Select c1 from table where c1 = ‘’
• Oracle
  – Insert into table (c1,c2) values ‘foo’, ‘ ‘)
  – Select c1 from table where c1 = ‘ ‘
Remote Objects
• MSSQL
  – Server_name.database_name.object_owner.object_name
  – Example:
     • Sqlserver1.sales.ny.acme.com.scott.emp




• ORACLE
  – Object_owner.object_name@database_name
  – Example
     • Scott.emp@sales.ny.acme.com
Operators
Operator                 MSSQL                    Oracle
Less than or equal to    <= or !>                 <=

Greater than or equal    >= or !<                 >=
to
Pattern matches          Like ‘a%’ or LIKE’a[x-z]’ Like ‘a%’
                                                   or LIKE ‘a%’
Equal to a member of a IN or =ANY                 =SOME or IN
set
Less than or equal to    <=ALL or !>all           <=all
every member of the
set
Greater than or equal    >=ALL or !<all           >=all
to every member of the
set
Functions
MSSQL               Oracle
Current_timestamp   sysdate

Current_user        user

Datalength          Length

Host_id             Userenv(‘terminal’)

Host_name           Userenv(‘host’)

Isdate              N/A

ISNULL              NVL

NULLIF              CASE

SESSION_USER        USER
STRING Functions
MSSQL             Oracle
CHAR              CHR

CHARINDEX         INSTR

LEFT(STR,N)       SUBSTR(STR,1,N)

LTRIM             LTRIM

NCHAR             N/A

REPLICATE(STR,)   SUBSTR(STR,-(N))

SPACE(N)          RPAD(‘ ‘,’N-1,’ ‘)

Str               TO_CHAR

UNICODE           N/A
Easy T-SQL example - MSSQL
Create proc proc1
As
Begin
  Declare @x int
  If exists (select * from table2)
  Select @x = -1
end
Easy T-SQL example - ORACLE
Create or replace procedure proc1
As
   V_x number(10);
   V_temp number(1,0) := 0;
Begin
   Select 1 into v_temp
   From dual
   where exists (select * from table2);
   If v_temp = 1 then
       V_x := -1;
   End if;
End;
T/SQL – Example - MSSQL
UPDATE admin_role SET template =
 '<?xml version="1.0" encoding="UTF-8"?>
 <templates>
     <package id="identity">
            <action name="read"></action>
     </package>
   <package id="metadata">
      <action name="read"></action>
   </package>
   <package id="ecommerce">
      <action name="access"></action>
   </package>
   <package id="redirect">
      <action name="read"></action>
      <action name="change"></action>
      <action name="create"></action>
      <action name="delete"></action>
   </package>…. **** Greater than 4000 Bytes
<backstage action="adminBackstage-setPriority" area="6"></backstage>
   <backstage action="adminBackstage-changeSubjHeading" area="6"></backstage>
</templates>'
 WHERE name = 'Publisher Super Admin'
T/SQL Conversion Example - Oracle
declare
template_lob2 clob;
begin
template_lob2 :='<?xml version="1.0" encoding="UTF-8"?>
<templates>
   <package id="identity">
     <action name="read"></action>
     <action name="change"></action>
     <action name="create"></action>
     <action name="delete"></action>
     <action name="changepwd"></action>
     <action name="settings"></action>
     <action name="impersonate"/>
   </package>…….*** Greater than 4000 Bytes
<backstage action="adminBackstage-changeSubjHeading" area="6"></backstage>
</templates>';
UPDATE admin_role set template=template_lob2 WHERE name = 'Publisher
    Super Admin';
Case example - MSSQL
update PUBLICATION
set Area = (select CASE
            WHEN Area LIKE '00000000%' THEN 0
            WHEN Area LIKE '00000001%' THEN 1
            WHEN Area LIKE '00000010%' THEN 2
            WHEN Area LIKE '00000100%' THEN 4
            WHEN Area LIKE '00001000%' THEN 8
            WHEN Area LIKE '00010000%' THEN 16
            WHEN Area LIKE '00100000%' THEN 32
            WHEN Area LIKE '01000000%' THEN 64
            WHEN Area LIKE '10000000%' THEN 128
            END
       from PUB_AREA_STR_BACKUP
       where PUBLICATION.pubid = PUB_AREA_STR_BACKUP.pubid)
where pubid in (select pubid from PUB_AREA_STR_BACKUP);
Case example - Oracle
update PUBLICATION set Area =
 (select decode(Area, '0000000000000000', 0,
                '0000000100000000', 1,
                '0000001000000000', 2,
                '0000100000000000', 8,
                '0001000000000000', 16,
                '0010000000000000', 32)
    from article_meta where article_meta.articleid =
   PUBLICATION.PubId)
where exists (select articleId from article_meta where
   PUBLICATION.pubid = article_meta.articleid and area is not null
   and area <> '0000010000000000');
Sequence Differences
• MSSQL
  – No Database Sequences
  – Example –
  CREATE TABLE SEQ_OFFERID_SEQ ( idvalue
   bigint IDENTITY(1,1) )
• T-SQL Example:
  declare @uid bigint
  exec nextval2 'UserID_SEQ', @uid output
  insert into change_record (userid, createupdatedate,
    action, sessionid, userid)
    values (@uid, getdate(), 0, -1, -1)
Miscellaneous
MSSQL sp_rename function
   if exists(select * from sysobjects where name =
       'SEQ_ECOMM2_CONTRACTTERM' and uid=user_id())
   exec sp_rename 'SEQ_ECOMM2_CONTRACTTERM',
       'SEQ_ECOMM2_CONTRACTTERM_SEQ';
   exec sp_rename 'Publication.IsRegistered', 'IsDoiRegistered',
       'COLUMN';
ORACLE sp_rename equivalent
  no oracle “sp_rename” equivalent – must use
  PL/SQL, or alter table.
VIEWS
• MSSQL doesn’t have create or replace view – so
  they drop first than create
CAST / Concatenation Diff
• Oracle
  – UPDATE ad_data SET description = 'Ad '||
    CAST(adId AS VARCHAR2(19)) WHERE
    description IS NULL;


• MSSQL
  – UPDATE ad_data SET description = 'Ad ' +
    CAST(adId AS VARCHAR) WHERE description IS
    NULL
References
• Migrating Applications from Microsoft SQL
  Server to Oracle 9i Database
  – Oracle White Paper
  – November 2003
• Microsoft SQL Server and Oracle Compared
  – Download.oracle.com/docs/
• Microsoft SQLServer 2005 for the
  experienced Oracle Database Administrator
  – Microsoft Course 7033A
Items Learned in this Session

• Basic differences between Oracle and MSSQL
   – Database, Instance, Memory and Storage
     Architecture
   – Terminology
• Database locks
• Data Objects
• Data Types
• DML Examples
Thank You for Attending
                            Thank you,

                            Questions?

                 Michael.gangler@ithaka.org

Please fill out your evaluation form.

         Migrating SQL Server 2005 Applications to Oracle
                          Mike Gangler
                         Paper # 2086

More Related Content

What's hot

A Practitioner's Guide to Successfully Migrate from Oracle to Sybase ASE Part 2
A Practitioner's Guide to Successfully Migrate from Oracle to Sybase ASE Part 2A Practitioner's Guide to Successfully Migrate from Oracle to Sybase ASE Part 2
A Practitioner's Guide to Successfully Migrate from Oracle to Sybase ASE Part 2
Dobler Consulting
 

What's hot (20)

Exploring Oracle Multitenant in Oracle Database 12c
Exploring Oracle Multitenant in Oracle Database 12cExploring Oracle Multitenant in Oracle Database 12c
Exploring Oracle Multitenant in Oracle Database 12c
 
MySQL 5.7 New Features for Developers
MySQL 5.7 New Features for DevelopersMySQL 5.7 New Features for Developers
MySQL 5.7 New Features for Developers
 
Oracle 12.2 sharded database management
Oracle 12.2 sharded database managementOracle 12.2 sharded database management
Oracle 12.2 sharded database management
 
PL/SQL New and Advanced Features for Extreme Performance
PL/SQL New and Advanced Features for Extreme PerformancePL/SQL New and Advanced Features for Extreme Performance
PL/SQL New and Advanced Features for Extreme Performance
 
Oracle Database | Computer Science
Oracle Database | Computer ScienceOracle Database | Computer Science
Oracle Database | Computer Science
 
Oracle dba
Oracle  dbaOracle  dba
Oracle dba
 
An Introduction To Oracle Database
An Introduction To Oracle DatabaseAn Introduction To Oracle Database
An Introduction To Oracle Database
 
2019 - GUOB Tech Day / Groundbreakers LAD Tour - Database Migration Methods t...
2019 - GUOB Tech Day / Groundbreakers LAD Tour - Database Migration Methods t...2019 - GUOB Tech Day / Groundbreakers LAD Tour - Database Migration Methods t...
2019 - GUOB Tech Day / Groundbreakers LAD Tour - Database Migration Methods t...
 
Oracle OpenWo2014 review part 03 three_paa_s_database
Oracle OpenWo2014 review part 03 three_paa_s_databaseOracle OpenWo2014 review part 03 three_paa_s_database
Oracle OpenWo2014 review part 03 three_paa_s_database
 
Mining the AWR: Alternative Methods for Identification of the Top SQLs (inclu...
Mining the AWR: Alternative Methods for Identification of the Top SQLs (inclu...Mining the AWR: Alternative Methods for Identification of the Top SQLs (inclu...
Mining the AWR: Alternative Methods for Identification of the Top SQLs (inclu...
 
A Practitioner's Guide to Successfully Migrate from Oracle to Sybase ASE Part 2
A Practitioner's Guide to Successfully Migrate from Oracle to Sybase ASE Part 2A Practitioner's Guide to Successfully Migrate from Oracle to Sybase ASE Part 2
A Practitioner's Guide to Successfully Migrate from Oracle to Sybase ASE Part 2
 
No sql bigdata and postgresql
No sql bigdata and postgresqlNo sql bigdata and postgresql
No sql bigdata and postgresql
 
MariaDB: Connect Storage Engine
MariaDB: Connect Storage EngineMariaDB: Connect Storage Engine
MariaDB: Connect Storage Engine
 
Things Every Oracle DBA Needs To Know About The Hadoop Ecosystem
Things Every Oracle DBA Needs To Know About The Hadoop EcosystemThings Every Oracle DBA Needs To Know About The Hadoop Ecosystem
Things Every Oracle DBA Needs To Know About The Hadoop Ecosystem
 
Big data for cio 2015
Big data for cio 2015Big data for cio 2015
Big data for cio 2015
 
Sas keyword
Sas keywordSas keyword
Sas keyword
 
Comparison between rdbms and nosql
Comparison between rdbms and nosqlComparison between rdbms and nosql
Comparison between rdbms and nosql
 
TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...
TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...
TechEvent 2019: Oracle to PostgreSQL - a Travel Guide from Practice; Roland S...
 
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
 
MySQL Cluster
MySQL ClusterMySQL Cluster
MySQL Cluster
 

Viewers also liked (8)

Who Am I
Who Am IWho Am I
Who Am I
 
Miriam
MiriamMiriam
Miriam
 
Mario5
Mario5Mario5
Mario5
 
Torre2010
Torre2010Torre2010
Torre2010
 
Who Am I
Who Am IWho Am I
Who Am I
 
Miriam
MiriamMiriam
Miriam
 
Building appsinsilverlight4 part_1
Building appsinsilverlight4 part_1Building appsinsilverlight4 part_1
Building appsinsilverlight4 part_1
 
Mgangler Virtualization
Mgangler VirtualizationMgangler Virtualization
Mgangler Virtualization
 

Similar to 2008 2086 Gangler

Similar to 2008 2086 Gangler (20)

Oracle DB
Oracle DBOracle DB
Oracle DB
 
Ora 4 the_sqldba
Ora 4 the_sqldbaOra 4 the_sqldba
Ora 4 the_sqldba
 
1650607.ppt
1650607.ppt1650607.ppt
1650607.ppt
 
SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
SQL Server 2014 Extreme Transaction Processing (Hekaton) - BasicsSQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
 
No SQL
No SQLNo SQL
No SQL
 
OracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive MetastoreOracleStore: A Highly Performant RawStore Implementation for Hive Metastore
OracleStore: A Highly Performant RawStore Implementation for Hive Metastore
 
MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTUREMS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
 
Oracle Database Introduction
Oracle Database IntroductionOracle Database Introduction
Oracle Database Introduction
 
CosmosDB for DBAs & Developers
CosmosDB for DBAs & DevelopersCosmosDB for DBAs & Developers
CosmosDB for DBAs & Developers
 
SQL Now! How Optiq brings the best of SQL to NoSQL data.
SQL Now! How Optiq brings the best of SQL to NoSQL data.SQL Now! How Optiq brings the best of SQL to NoSQL data.
SQL Now! How Optiq brings the best of SQL to NoSQL data.
 
Sql vs NoSQL-Presentation
 Sql vs NoSQL-Presentation Sql vs NoSQL-Presentation
Sql vs NoSQL-Presentation
 
DBA 101 : Calling all New Database Administrators (PPT)
DBA 101 : Calling all New Database Administrators (PPT)DBA 101 : Calling all New Database Administrators (PPT)
DBA 101 : Calling all New Database Administrators (PPT)
 
Introduction to SharePoint for SQLserver DBAs
Introduction to SharePoint for SQLserver DBAsIntroduction to SharePoint for SQLserver DBAs
Introduction to SharePoint for SQLserver DBAs
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
 
Oracle 10g Introduction 1
Oracle 10g Introduction 1Oracle 10g Introduction 1
Oracle 10g Introduction 1
 
MyHeritage backend group - build to scale
MyHeritage backend group - build to scaleMyHeritage backend group - build to scale
MyHeritage backend group - build to scale
 
Best Oracle dba online training institute
Best Oracle dba online training instituteBest Oracle dba online training institute
Best Oracle dba online training institute
 
SharePoint Storage Best Practices
SharePoint Storage Best PracticesSharePoint Storage Best Practices
SharePoint Storage Best Practices
 
Oracle DBA
Oracle DBAOracle DBA
Oracle DBA
 
Nosql data models
Nosql data modelsNosql data models
Nosql data models
 

More from Secure-24 (9)

2019 odtug webinar-20190129
2019 odtug webinar-201901292019 odtug webinar-20190129
2019 odtug webinar-20190129
 
Gloc gangler 2018._v4
Gloc gangler 2018._v4Gloc gangler 2018._v4
Gloc gangler 2018._v4
 
2016_1201_gangler_ppt
2016_1201_gangler_ppt2016_1201_gangler_ppt
2016_1201_gangler_ppt
 
Granting Oracle Schema Permissions when Objects not created Yet
Granting Oracle Schema Permissions when Objects not created YetGranting Oracle Schema Permissions when Objects not created Yet
Granting Oracle Schema Permissions when Objects not created Yet
 
Using RPM's to Automagically to install Oracle Agents to EM12C
Using RPM's to Automagically to install Oracle Agents to EM12CUsing RPM's to Automagically to install Oracle Agents to EM12C
Using RPM's to Automagically to install Oracle Agents to EM12C
 
Optimize and Simplify Oracle 12C RAC using dNFS, ZFS and OISP
Optimize and Simplify Oracle 12C RAC using dNFS, ZFS and OISPOptimize and Simplify Oracle 12C RAC using dNFS, ZFS and OISP
Optimize and Simplify Oracle 12C RAC using dNFS, ZFS and OISP
 
2015 582 gangler_ppt - ms
2015 582 gangler_ppt - ms2015 582 gangler_ppt - ms
2015 582 gangler_ppt - ms
 
Using oracle12c pluggable databases to archive
Using oracle12c pluggable databases to archiveUsing oracle12c pluggable databases to archive
Using oracle12c pluggable databases to archive
 
EM12C High Availability without SLB and RAC
EM12C High Availability without SLB and RACEM12C High Availability without SLB and RAC
EM12C High Availability without SLB and RAC
 

2008 2086 Gangler

  • 1. 2086/Migrating SQL Server 2005 Applications to Oracle Mike Gangler Ithaka / JStor Session # 2086
  • 2. Speaker and Company Information • Database Specialist with JSTOR – www.jstor.org • 20+ Years DBA experience • Presented Collaborate in ’07, SEMOP, Regional user Groups and at many IOUG-Alive events • Experience with FOCUS, IMS DB/DC, DB2, Sybase, and MSSQL 6.5 databases prior to assignment. • JSTOR - is a not-for-profit organization dedicated to helping the scholarly community discover, use, and build upon a wide range of intellectual content in a trusted digital archive. We collaborate with organizations that benefit the scholarly community.
  • 3. Agenda • Introduction • Overview of Problem • Basic and Fundamental Differences • Database Locking • • Data Objects • Data Types • Data Access – DML and Examples
  • 4. Introduction • This session will describe the lessons learned during the process of converting an MSSQL database application to Oracle. • Session targeted towards Oracle DBA’s with little or no MSSQL experience. • JSTOR purchased a 3rd party product that was using primarily MSSQL. • Agreement was that JSTOR would convert MSSQL patches and coding to Oracle (If and when needed). • Project started in 2006 and we launched the new product in April 2008. • Using Oracle 10G release 2 and Grid Control on Sun Solaris X86-64 machines • 3rd Party using SQL Server 2005
  • 5. Overview of Problem • JSTOR Is primarily a Oracle Shop • 3rd Party is primarily a MSSQL Shop • Coding was supposed to be “Database Agnostic” • Limited assistance from 3rd Party • Limited experience with MSSQL • 2 development centers – Santa Clara and Ann Arbor – code control – version control – little or no communication • 3 – 5 patches a day
  • 6. Basic and Fundamental Differences • Database, Instance and Storage Architecture – Terminology – Characteristic Differences – Comparison of Core Objects – Storage Architecture – Data Blocks, Extents and Segments – Memory Address Space – Oracle – Memory Address Space – MSSQL – Process and Thread-based Architecture – Background Processes
  • 7. Basic and Fundamental Differences - Database and Instance • Terminology – – Oracle Instance = Memory and Processes related to a Database. – Oracle Database = Files containing application and system information – MSSQL Instance = set of binaries isolating the SQL Server database Engine Services. • Every Instance will have its own system database and separate Admin parms. – MSSQL Database = Oracle schema with a Master DB (System Tables).
  • 8. Basic and Fundamental Differences – Database and Instance Characteristic Oracle SQL Server Minimum Block Size 2KB 8KB Maximum Block Size 16KB 8KB Maximum Blocks Per File 4 Million blocks 2 Million Blocks Maximum File Size 64Gb 16TB Maximum # of Files 65K 32K Maximum DB Size 4PB 1EB Instances Per Server Based on Server 50 Resources Max # of tablespaces 65K 32K File Groups Max log file size 64 Gb 32TB Max # of tablespaces 65K 32K File Groups
  • 9. Basic and Fundamental Differences – Comparison of Core Objects Oracle SQL Server Table Table Index Index View View Synonym Synonym Sequence N/A Procedure Stored Procedure Function Function Package N/A Streams Service Broker Queue XMLDB XML Schema Collection Object Type Type
  • 10. Basic and Fundamental Differences – Storage Architecture • Physical – Oracle Data file = MSSQL data file or Device • Logical – Oracle tablespace = MSSQL File Group – Oracle Segment = MSSQL Heap/Index – Oracle Extent = MSSQL Extent – Oracle Blocks = MSSQL Pages
  • 11. Basic and Fundamental Differences –Data Blocks, Extents and segments • Smallest unit of logical storage – Oracle = Block – MSSQL = Page • Block size – Oracle is variable – MSSQL is fixed at 8kb • Extent size – Oracle is variable – MSSQL are fixed at 64kb
  • 12. Basic and Fundamental Differences –Memory Address Space - Oracle • Memory Allocation Concepts – Oracle – Oracle is static – Allocated at Startup – MSSQL is Dynamic – Variables set by administrator – ASSM introduced in Oracle 10g
  • 13. Basic and Fundamental Differences –Memory Address Space – MSSQL 2005 • Memory Allocation Concepts – MSSQL 2005 – Allocations are constantly changed based on RDBMS needs and operating system needs (Self Tuning). – Allocation is dynamic at higher level (Memory pool, etc.) and lower level ( Buffer cache, procedure cache, etc.) components. – Very Few configurable parameters – Min server memory and max server memory settings • Memory address range – Leveraging Address Windowing Extensions (AWE)
  • 14. Basic and Fundamental Differences –Process and Thread-based Architecture • Process is an independent piece of code with its own memory space • Thread is spawned by a process and works within the parents memory space • Advantages of using Threads: – Reduced overhead in context switching and reduction in overall memory requirements – Microsoft fibers are light-weight threads further reduces context switching overheads by running purely in user mode • Oracle uses processes in Unix and Threads in Windows • Both Oracle and SQL Server use threads and optionally fibers. Threads/fibers are scheduled onto a CPU by a user mode Scheduler (UMS) • Process/thread can be tied to processors in both Oracle (Windows) and SQL Server 2005 using CPU affinity feature.
  • 15. Basic and Fundamental Differences – Background Processes Oracle Oracle ID SQL Server required Processes Process PMON SQLOS Mandatory monitor System SMON Database Mandatory Monitor Cleanups and Shrinking DB Writers DBWn Lazywriter Mandatory Checkpoint CKPT Database Mandatory Processes Checkpoint Recoverer RECO MS DTC Optional Logwriter LGWR Log Writer Mandatory
  • 16. Basic and Fundamental Differences – Background Processes Oracle Oracle ID SQL Server required Processes Archive ARCn N/A N/A Job Queue Jnnn SQL Agent Mandatory Process Parallel Pnnn Worker Optional Slave Threads processes Dispatcher Dnnn Networker Mandatory Threads Shared Snnn Worker Mandatory Servers Threads
  • 17. Database Locking • MSSQL – Prior to SQLSERVER 2005 – Select statements obtain shared locks on pages/rows. • Prevents other statements from obtaining an exclusive lock on those pages/rows. • All Update statements require exclusive lock. • These locks will lock all update transactions until the select commits or roll backs. • transactions are physically serialized whenever 1 transaction selects the data and 1 changes. • ORACLE – – Readers don’t block writers and writers don’t block readers.
  • 18. Database Locking – Row Vs Page • MSSQL – Prior to MSSQL 2005 no row level locking – Does page level locking, which blocks all rows on the page. – MSSQL2005 – does a form of row level locking. – MSSQL2005 – Escalates locks at row level to page level automatically. • ORACLE – Row level locking – Only one row is locked when DML is changing the row.
  • 19. Data Objects Oracle SQL Server Heap-Organized Table Heap Clustered Table N/A Partitioned Table N/A Nested Table N/A Temporary Table Temporary Table External Table ** Linked Server Feature Object Table Table Variable Indexed-Organized Table Clustered Index
  • 20. Data Objects - Table • Heap is the default Form of data organization in a table, where data is stored in an unordered manner • In Oracle, Index Organized Tables store data in a B- Tree structure in primary key order. • SQL Server offers clustered indexes where data can be ordered by any column • Oracle and MSSQL offer local and global temporary tables to store transient application data
  • 21. Data Objects – Indexes (Diff) Index Scheme Oracle MSSQL B-tree Composite Yes (32 Cols) Yes (16 Cols) B-Tree Reverse Yes No B-Tree Key Compressed Yes No B-Tree Function Based Yes No B-Tree IOT Yes Yes (Clustered) B-Tree Partition Yes No Bitmap Yes No Bitmap Join Yes No
  • 22. Data Objects – Views (Diff) View Type Oracle MSSQL Object Views Yes No Indexed Views No Yes Updateable Views – Restrictions in MSSQL can be bypassed by defining a “INSTEAD OF” trigger on the view. INLINE Views – MSSQL use Derived tables and CTE (Common table Expressions)
  • 23. Data Types – Character Based Oracle Type Oracle Size SQL Type SQL Size Char 1 – 2000 Char 1 - 8000 NChar 1 – 2000 NChar 1 – 4000 Varchar 1 – 4000 Varchar 1 - 8000 NVarchar 1 – 4000 NVarchar 1 - 8000 Varchar2 1 – 4000 Varchar 1 - 8000 NVarchar2 1 – 4000 Nvarchar 1 - 8000 LONG 1 – 2Gb Text 2GB CLOB 4GB Text 2GB NCLOB 4GB NText 2GB BLOB 4GB Image 2GB
  • 24. Data Types – Numeric Data Oracle Type SQL Type Number(19,0) Bigint Int / Number(10,0) int Smallint / smallint Number(6,0) Number(3,0) tinyint Number(p,0) decimal Number(p,0) Numeric(p,s) Float / Number(38) Float Number(1) Bit Number(19,4) Money Number(10,4) Small Money
  • 25. Data Types – Other Types Oracle Type SQL Type Date datetime Date Smalldatetime Timestamp datetime RAW(n) / BLOB Binary(n) RAW(n) / BLOB VARBINARY(n) FLOAT FLOAT REAL FLOAT
  • 26. Date Data Types • MSSQL datetime accurate up to 3.33 Milliseconds. • Oracle “date” is accurate up to 1 second. • Oracle’s timestamp up to 1 Millisecond. • MSSQL “smalldatetime” up to 1 Minute. • If application requires sub second Date Precision use Oracle’s “timestamp”. • MSSQL “timestamp” not related to “datetime” – MSSQL2005 – “timestamp” = SQL2000 – “rowversion. – It's a unique value which is changed every time the row is updated
  • 27. Data Access – DML and Examples MSSQL Oracle GO Semi Colon (;) Select sqrt(100) Select sqrt(100) from dual Select ‘last Name’=lastname Select lastname “Last Name” from …. from …. Or Select lastname as ‘last name’ from …. Select lastname +’,’+firstname Select lastname||’,’||firstname from …. from … Select top 5 from table Select * from table where rownum <=5
  • 28. Data Access – DML and examples MSSQL Oracle Left outer Join Where ta.col(+) = tb.col Nullif(exp,exp) case ISNULL(EXP,VAL) NVL(exp,val) Select getdate() Select sysdate from dual Case Case or decode Select 3+5 (from not required) Select 3+5 from dual Create procedure Create or replace procedure Sp_rename n/a – procedure to emulate the sp_rename function.
  • 29. Select clause Differences • MSSQL – “TOP” – “IDENTITYCOL” – “ROWGUIDCOL” – Column Alias – select c1 = ‘alias’ from t1 • ORACLE – Select c1 from t1 where rownum < n – Doesn’t support “identitycol” – Doesn’t support “rowguidcol” (sys_guid) – Column alias – select c1 “alias’ from t1
  • 30. Update Statements • MSSQL – Supports a “FROM” clause – MSSQL Example: • Update t1 set col1=0 from t1=a, t2=b where a.c2 = b.c2 • ORACLE – Doesn’t Support a “FROM” clause – Oracle Example: • Update t1 set col1=0 where col1 in (select col1 from t2 where c3 = ‘USA’)
  • 31. Delete Statements • MSSQL – Supports a “FROM” clause – MSSQL Example: • Delete tableA from tableA a, tableB b where a.c1 = b.c1 • ORACLE – Doesn’t Support a “FROM” clause – Oracle Example: • Delete tableA a • Where exists (select * from tableB b where a.c1 = b.c1)
  • 32. “Into” Clause • MSSQL – Select * into t1 from t2 – Insert * into t1 from t2 • ORACLE – Create table t1 as select * from t2 – Insert into t1 as select * from t2
  • 33. Global Tables Examples • MSSQL Create table #a_temp_table (col1 INT, col2 char(1)) • Oracle Create global temporary table tt_a_temp_table (col1 number(6), col2 char(1)) On commit reserve rows
  • 34. Empty String Literals • MSSQL – interprets empty string as a single blank space • Oracle – interprets empty string as NULL • MSSQL – Insert into table (c1, c2) values (‘foo’,’’) – Select c1 from table where c1 = ‘’ • Oracle – Insert into table (c1,c2) values ‘foo’, ‘ ‘) – Select c1 from table where c1 = ‘ ‘
  • 35. Remote Objects • MSSQL – Server_name.database_name.object_owner.object_name – Example: • Sqlserver1.sales.ny.acme.com.scott.emp • ORACLE – Object_owner.object_name@database_name – Example • Scott.emp@sales.ny.acme.com
  • 36. Operators Operator MSSQL Oracle Less than or equal to <= or !> <= Greater than or equal >= or !< >= to Pattern matches Like ‘a%’ or LIKE’a[x-z]’ Like ‘a%’ or LIKE ‘a%’ Equal to a member of a IN or =ANY =SOME or IN set Less than or equal to <=ALL or !>all <=all every member of the set Greater than or equal >=ALL or !<all >=all to every member of the set
  • 37. Functions MSSQL Oracle Current_timestamp sysdate Current_user user Datalength Length Host_id Userenv(‘terminal’) Host_name Userenv(‘host’) Isdate N/A ISNULL NVL NULLIF CASE SESSION_USER USER
  • 38. STRING Functions MSSQL Oracle CHAR CHR CHARINDEX INSTR LEFT(STR,N) SUBSTR(STR,1,N) LTRIM LTRIM NCHAR N/A REPLICATE(STR,) SUBSTR(STR,-(N)) SPACE(N) RPAD(‘ ‘,’N-1,’ ‘) Str TO_CHAR UNICODE N/A
  • 39. Easy T-SQL example - MSSQL Create proc proc1 As Begin Declare @x int If exists (select * from table2) Select @x = -1 end
  • 40. Easy T-SQL example - ORACLE Create or replace procedure proc1 As V_x number(10); V_temp number(1,0) := 0; Begin Select 1 into v_temp From dual where exists (select * from table2); If v_temp = 1 then V_x := -1; End if; End;
  • 41. T/SQL – Example - MSSQL UPDATE admin_role SET template = '<?xml version="1.0" encoding="UTF-8"?> <templates> <package id="identity"> <action name="read"></action> </package> <package id="metadata"> <action name="read"></action> </package> <package id="ecommerce"> <action name="access"></action> </package> <package id="redirect"> <action name="read"></action> <action name="change"></action> <action name="create"></action> <action name="delete"></action> </package>…. **** Greater than 4000 Bytes <backstage action="adminBackstage-setPriority" area="6"></backstage> <backstage action="adminBackstage-changeSubjHeading" area="6"></backstage> </templates>' WHERE name = 'Publisher Super Admin'
  • 42. T/SQL Conversion Example - Oracle declare template_lob2 clob; begin template_lob2 :='<?xml version="1.0" encoding="UTF-8"?> <templates> <package id="identity"> <action name="read"></action> <action name="change"></action> <action name="create"></action> <action name="delete"></action> <action name="changepwd"></action> <action name="settings"></action> <action name="impersonate"/> </package>…….*** Greater than 4000 Bytes <backstage action="adminBackstage-changeSubjHeading" area="6"></backstage> </templates>'; UPDATE admin_role set template=template_lob2 WHERE name = 'Publisher Super Admin';
  • 43. Case example - MSSQL update PUBLICATION set Area = (select CASE WHEN Area LIKE '00000000%' THEN 0 WHEN Area LIKE '00000001%' THEN 1 WHEN Area LIKE '00000010%' THEN 2 WHEN Area LIKE '00000100%' THEN 4 WHEN Area LIKE '00001000%' THEN 8 WHEN Area LIKE '00010000%' THEN 16 WHEN Area LIKE '00100000%' THEN 32 WHEN Area LIKE '01000000%' THEN 64 WHEN Area LIKE '10000000%' THEN 128 END from PUB_AREA_STR_BACKUP where PUBLICATION.pubid = PUB_AREA_STR_BACKUP.pubid) where pubid in (select pubid from PUB_AREA_STR_BACKUP);
  • 44. Case example - Oracle update PUBLICATION set Area = (select decode(Area, '0000000000000000', 0, '0000000100000000', 1, '0000001000000000', 2, '0000100000000000', 8, '0001000000000000', 16, '0010000000000000', 32) from article_meta where article_meta.articleid = PUBLICATION.PubId) where exists (select articleId from article_meta where PUBLICATION.pubid = article_meta.articleid and area is not null and area <> '0000010000000000');
  • 45. Sequence Differences • MSSQL – No Database Sequences – Example – CREATE TABLE SEQ_OFFERID_SEQ ( idvalue bigint IDENTITY(1,1) ) • T-SQL Example: declare @uid bigint exec nextval2 'UserID_SEQ', @uid output insert into change_record (userid, createupdatedate, action, sessionid, userid) values (@uid, getdate(), 0, -1, -1)
  • 46. Miscellaneous MSSQL sp_rename function if exists(select * from sysobjects where name = 'SEQ_ECOMM2_CONTRACTTERM' and uid=user_id()) exec sp_rename 'SEQ_ECOMM2_CONTRACTTERM', 'SEQ_ECOMM2_CONTRACTTERM_SEQ'; exec sp_rename 'Publication.IsRegistered', 'IsDoiRegistered', 'COLUMN'; ORACLE sp_rename equivalent no oracle “sp_rename” equivalent – must use PL/SQL, or alter table. VIEWS • MSSQL doesn’t have create or replace view – so they drop first than create
  • 47. CAST / Concatenation Diff • Oracle – UPDATE ad_data SET description = 'Ad '|| CAST(adId AS VARCHAR2(19)) WHERE description IS NULL; • MSSQL – UPDATE ad_data SET description = 'Ad ' + CAST(adId AS VARCHAR) WHERE description IS NULL
  • 48. References • Migrating Applications from Microsoft SQL Server to Oracle 9i Database – Oracle White Paper – November 2003 • Microsoft SQL Server and Oracle Compared – Download.oracle.com/docs/ • Microsoft SQLServer 2005 for the experienced Oracle Database Administrator – Microsoft Course 7033A
  • 49. Items Learned in this Session • Basic differences between Oracle and MSSQL – Database, Instance, Memory and Storage Architecture – Terminology • Database locks • Data Objects • Data Types • DML Examples
  • 50. Thank You for Attending Thank you, Questions? Michael.gangler@ithaka.org Please fill out your evaluation form. Migrating SQL Server 2005 Applications to Oracle Mike Gangler Paper # 2086