oracle vs. ms sql server

13

Click here to load reader

Upload: teresa-rothaar

Post on 16-Apr-2017

5.159 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Page 1: Oracle vs. MS SQL Server

Running Head: ORACLE DATABASE VS. MICROSOFT SQL SERVER 1

Oracle Database vs. Microsoft SQL Server

Teresa J. Rothaar

Wilmington University

Page 2: Oracle vs. MS SQL Server

ORACLE DATABASE VS. MICROSOFT SQL SERVER

Oracle Database vs. Microsoft SQL Server

Introduction

Oracle and Microsoft SQL Server are competing relational database systems. Both are

proprietary packages, as opposed to open source systems such as MySQL. Oracle’s relational

database product dominates the database market, controlling more than 48% of the market as of

2010 (Hoffer, 2013, p. 246). However, Microsoft SQL Server gained 2,000 Enterprise customers

between 2010 and 2012, with its overall market share growing faster than that of its competitors

(Backaitis, 2014).

Oracle boasts the ability to run on a wide variety of platforms, including Windows, Mac,

and UNIX. Microsoft SQL Server is available only for Windows (Leiba, 2003), which limits the

latter’s potential customer base, which is possibly why SQL Server ranks third in the overall

database market (Hoffer, p. 246). However, unlike Oracle, Microsoft SQL Server has a large,

enthusiastic community of product evangelists, which is supported by Microsoft itself (McCown,

2008). The impact of product evangelism could explain SQL Server’s exponential growth

despite its vendor lock-in to the Windows OS.

This paper will explore some of the differences between Oracle and SQL Server, with a

focus on data types and other issues that are important for database administrators who work

with both systems to understand, especially in situations where data is being migrated from one

system to the other.

Database Architecture

An Oracle database is just that: one database, with all objects within it grouped by

schemas, and with the objects shared by all users and schemas. However, the database

administrator can set user privileges that allow access to some schemas and objects but not

2

Page 3: Oracle vs. MS SQL Server

ORACLE DATABASE VS. MICROSOFT SQL SERVER

others. SQL Server contains multiple databases, with each database having its own private,

unshared server file disk. All objects are assigned to a particular database, and users have

individual logins that grant access to a database and its corresponding objects (Stansfield, 2014).

This difference in architecture means that the concept of “logging onto the database”

means different things in each system. On SQL Server, a user who is logged onto the server can

execute the USE DATABASE_NAME command to switch to another database on that server, so

long as the user has access privileges allowing them to do so. Because an Oracle installation

contains only one database, there is no such thing as “switching databases.” There is only

viewing a different schema or object. To do that, the user executes a CONNECT command under

a different user name, or alternatively uses a SET ROLE command to change roles (Oracle

Corporation).

T-SQL vs. PL/SQL

Because they use different proprietary programming languages, Oracle and SQL Server

handle stored procedures quite differently. Oracle uses the PL/SQL programming language,

which is based on Ada, while Microsoft uses T-SQL, or Transactional SQL, which is based on

Sysbase (Burleson Consulting, 2011). In SQL Server, stored procedures are not compiled until

executed, which means any errors are not discovered until a procedure is actually run. There is

also is no ability to read or write from external files from a stored procedure (Leiba).

Oracle also offers a “black box” of certain stored procedures and functions that share all

input, output, and variables, called a “package.” Among other benefits, packages allow top-

down, object oriented design and performance improvement. Most of Oracle’s built-in functions

are part of a package. There is no equivalent to this in SQL Server, so when converting from

Oracle to SQL Server, the packages need to be broken down into multiple processes, user-

3

Page 4: Oracle vs. MS SQL Server

ORACLE DATABASE VS. MICROSOFT SQL SERVER

defined functions, and so on. When going from SQL Server to Oracle, the opposite occurs:

multiple processes, user-defined functions, and shared variables can be combined as part of an

Oracle package (Kline, 2005).

Oracle and Microsoft handle updates to their proprietary languages differently. While

Oracle releases new versions of PL/SQL separately from their RDBMS product—because

PL/SQL is used in other Oracle software—Microsoft updates T-SQL only when issuing a new

version of SQL Server. Therefore, every version of T-SQL is linked to a specific version of SQL

Server (Kline).

Reserved Words

Many words that can be used as column headings or object names in SQL Server, such as

DATE, are reserved words in Oracle, and thus these names cannot be directly transferred from

SQL Server to Oracle (Oracle Corporation, n.d.).

Date & Time Data Types

Although both databases store point-in-time values for DATE and TIME data types,

Oracle and SQL Server date and time ranges are very different. In Oracle, they range from 4712

B.C. to 4712 A.D., while the SQL Server date range is from 1753 A.D. to 9999 A.D. (Microsoft

Developer Network, n.d.). Additionally, the date/time precision in Microsoft SQL Server is

1/300th of a second, while Oracle’s data type TIMESTAMP is much more exacting, measuring

time in increments of 1/100000000th of a second (Oracle Corporation).

A few date and time data types have no direct equivalents between the two DBMSes,

such as DATE and TIME in SQL Server, which store each attribute as an individual component,

and the Oracle data types INTERVAL YEAR TO MONTH or INTERVAL DAY TO SECOND,

which are used for periods of time as opposed to specific dates and times (Snaidero, 2013).

4

Page 5: Oracle vs. MS SQL Server

ORACLE DATABASE VS. MICROSOFT SQL SERVER

When migrating from Oracle to SQL Server, columns of type DATE containing values

that are out of range for SQL Server are converted to type VARCHAR(19) (Microsoft Developer

Network). Conversely, Oracle uses its data type TIMESTAMP for data that requires finer date

and time precision than seconds, such as scientific applications, which may require values as tiny

as nanoseconds. If such precision is not required, Oracle’s DATE data type, which is accurate to

one second, may be used.

Numeric Data Types

SQL Server has several integer data types based on size: TINYINT, SMALLINT, INT

and BIGINT. Oracle simplifies things with its NUMBER(x, y) data type, where x specifies the

size (or precision) required, and y specifies the scale (the numbers to the right of the decimal

point). For an integer, NUMBER(x, 0), should be used, with x representing the size required,

with the scale set to 0 (Snaidero).

SQL Server data types DECIMAL[(x,[y])] and NUMERIC[(x,[y])] are equivalent to

NUMBER(x, y) in Oracle (Snaidero). However, the systems treat precision and scale of numbers

very differently, which can cause issues when migrating from Oracle to SQL Server. While

Oracle allows numbers to be defined with a scale greater than the precision, i.e., NUMBER(4,5),

SQL Server requires that the precision be greater than or equal to the scale, and it will correct

this by setting the precision and scale equal to each other during migration. Thus, NUMBER(4,5)

would be mapped to NUMERIC(5,5). Additionally, when encountering a NUMBER data type

with no scale or precision specified, SQL Server defaults to the maximum scale and precision,

mapping to NUMERIC(8,38) (Microsoft Developer Network). Microsoft therefore recommends

that, prior to the data being migrated, a specific scale and precision be specified in Oracle as to

protect data integrity.

5

Page 6: Oracle vs. MS SQL Server

ORACLE DATABASE VS. MICROSOFT SQL SERVER

SQL Server has two data types, MONEY and SMALLMONEY, specifically for currency

values (Snaidero). Oracle, however, assumes an international customer base where users do not

necessarily count money in U.S. Dollars, and currency values are mapped to the NUMBER data

type (Oracle Corporation).

Character String Data Types

The Oracle equivalent of SQL Server data type VARCHAR is CLOB (Microsoft

Developer Network). SQL Server data type CHAR maps directly to Oracle type CHAR, but with

a caveat: it maps directly only for CHAR sizes of 1 through 2000. CHAR data types sized from

2001 to 4000 are invalid in Oracle, and Oracle will convert CHAR types in this size range to

VARCHAR2 (Oracle Corporation). Conversely, an Oracle VARCHAR2 type will map to SQL

Server type VARCHAR (Microsoft Developer Network).

SQL Server type TEXT maps to Oracle type CLOB (Oracle Corporation), but CLOB is

mapped to SQL Server type VARCHAR(MAX) (Microsoft Developer Network).

Binary and XML Data Types

SQL Server types BINARY and VARBINARY map to Oracle type RAW or BLOB,

depending on size (Oracle Corporation). However, while Oracle can support up to 4GB of data,

SQL Server can support only 2GB, and any data above that amount is truncated (Microsoft

Developer Network).

Both systems support XML data types. Oracle has type XMLTYPE, and the SQL Server

equivalent is simply XML. However, while SQL Server can hold only 2GB of data, Oracle can

hold up to 6GB (Snaidero)

6

Page 7: Oracle vs. MS SQL Server

ORACLE DATABASE VS. MICROSOFT SQL SERVER

Boolean Values

The SQL Server data type BIT, used for Boolean values, has no direct equivalent in

Oracle. However, BIT can be mapped to either NUMBER(1) or CHAR, with PL/SQL functions

used to query the value (Oracle Corporation).

Conclusion

There are many other differences between Oracle and SQL Server, such as how each

RDBMS handles exceptions, the type of functions that can be called within each environment,

and how SQL statements such as CREATE and INSERT are handled. Multiple resources are

available online, from the manufacturers and each product’s user community, to aid database

administrators as they work with both systems.

7

Page 8: Oracle vs. MS SQL Server

ORACLE DATABASE VS. MICROSOFT SQL SERVER

References

Backaitis, V. (2014, March 18). Microsoft SQL Server Wins in a Big Data World. CMSWire.

Retrieved from http://www.cmswire.com/cms/big-data/microsoft-sql-server-wins-in-a-

big-data-world-024565.php

Burleson Consulting. (2011, December 27). Data Type Issues with Microsoft SQL Server 2000

and Oracle 10g. Retrieved from

http://www.dba-oracle.com/t_migrating_sql_server_vs_oracle_datatypes.htm

Hoffer, J. A., & Ramesh, V. (2013). Modern Database Management (11th ed.). Boston: Pearson.

Kline, K. (2005, June). Translating Procedural Statements Between Oracle and SQL Server:

White Paper. Retrieved from

http://www.quest.com/whitepapers/TranslatingProceduralStatements_Oracle_SQLServer.

pdf

Leiba, E. (May 2003). Oracle vs. SQL Server: Why Oracle wins. TechTarget. Retrieved from

http://searchoracle.techtarget.com/tip/Oracle-vs-SQL-Server-Why-Oracle-wins

McCown, S. (2008, March 19). The Real Difference Between SQL Server and Oracle.

InfoWorld. Retrieved from http://www.infoworld.com/d/data-management/real-

difference-between-sql-server-and-oracle-755

Microsoft Developer Network. (n.d.). Data Type Mapping for Oracle Publishers. Retrieved from

http://msdn.microsoft.com/en-us/library/ms151817.aspx

Oracle Corporation. (n.d.) Oracle® Database SQL Developer Supplementary Information for

Microsoft SQL Server Migrations, Release 1.2. Retrieved from

http://docs.oracle.com/cd/E10405_01/doc/appdev.120/e10379/ss_oracle_compared.htm#

BGBDEBFA

8

Page 9: Oracle vs. MS SQL Server

ORACLE DATABASE VS. MICROSOFT SQL SERVER

Snaidero, B. (2013, April 25). Comparing SQL Server and Oracle Data Types. MSSQLTips.com.

Retrieved from http://www.mssqltips.com/sqlservertip/2944/comparing-sql-server-and-

oracle-datatypes/

Stansfield, J. (2014, March 13). Microsoft SQL Server vs. Oracle: The Same, But Different?

Segue Technologies Blog. Retrieved from

http://www.seguetech.com/blog/2014/03/13/Microsoft-SQL-Server-versus-oracle

9