# Sunday, November 18, 2007

Just noticed these two gems (again from the MSDN Architecture Center):

Guide to Migrating from Oracle to SQL Server 2005

Summary: "This white paper explores challenges that arise when you migrate from an Oracle 7.3 database or later to SQL Server 2005. It describes the implementation differences of database objects, SQL dialects, and procedural code between the two platforms. The entire migration process using SQL Server Migration Assistant for Oracle (SSMA Oracle) is explained in depth, with a special focus on converting database objects and PL/SQL code."

Guide to Migrating from Sybase ASE to SQL Server 2005

Summary: "This white paper covers known issues for migrating Sybase Adaptive Server Enterprise database to SQL Server 2005. Instructions for handling the differences between the two platforms are included. The paper describes how SQL Server Migration Assistant, the best tool for this type of migration, can help resolve various migration issues."

I definitely could have used these two documents a few months ago!

I hope this helps!

posted on Sunday, November 18, 2007 1:32:59 PM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback
# Monday, May 28, 2007

Yesterday, I detailed how to setup an Oracle database server on Windows Server 2003 in Oracle for Microsoft Developers, Part I: Installing Oracle 9.2 on Windows Server 2003.  Today, I want to step back  a little, take a look at some of the conceptual differences between Oracle and SQL Server, and then provide steps you can take to setup an Oracle database that you can use within your applications.

You may be saying to yourself, "Why should I care how to setup an Oracle database server and database?  I work with SQL Server, .NET, and could care less!  Let the DBAs concern themselves with Oracle!"  Now, I can't discount your sentiments - I've been there myself!  However, over the years, I've discovered two compelling reasons to take the time to learn more about Oracle: 1) it's always good to have more tools in your tool belt, and 2) getting DBAs to respond to your requests can occasionally be a long and arduous process.  If you have the know-how and acumen to setup an Oracle environment for yourself, I believe you'll find your ability to deliver on your development projects will be greatly enhanced.

Okay, that said, let's take a look at some important Oracle concepts.

Oracle Concepts

Tablespace

The Oracle tablespace is the lowest logical layer of the Oracle data structure. The tablespace consists of one or more datafiles, which are typically files on the operating system filesystem.  The space specified for a tablespace is allocated on the filesystem, but is not used until somebody creates a file or saves some data.

Think of the Tablespace as functionally equivalent to the data file (MDF) and log file (LDF) in SQL Server

Schema

A schema is a collection of objects associated with the database.  These objects are abstractions or logical structures that refer to database objects or structures. Schema objects consist of such things as clusters, indexes, packages, sequences, stored procedures, synonyms, tables, views, and so on.

I find it difficult to exactly correlate an Oracle schema to a concept in SQL Server.  I suppose it would be safe to say that a schema is similar to an object within SQL Server (such as a table or view) that's attached to a particular owner (such as dbo).

Data Dictionary

The data dictionary is a set of tables Oracle uses to maintain information about the database. The data dictionary contains information about tables, indexes, clusters, and so on.

The data dictionary is similar to the system tables that exist within SQL Server.

Database

The physical layer of the database consists of three types of files:

  • One or more datafiles
  • Two or more redo log files
  • One or more control files

The logical layer of the database consists of the following elements:

  • One or more tablespaces.
  • The database schema, which consists of items such as tables, clusters, indexes, views, stored procedures, database triggers, sequences, and so on.

The database is divided into one or more logical pieces known as tablespaces. A tablespace is used to logically group data together. Tablespaces consist of one or more datafiles. By using more than one datafile per tablespace, you can spread data over many different disks to distribute the I/O load and improve performance.

As part of the process of creating the database, Oracle automatically creates the SYSTEM tablespace for you. Although a small database can fit within the SYSTEM tablespace, it's recommended that you create a separate tablespace for user data. The SYSTEM tablespace is where the data dictionary is kept.

Administrative accounts

  • INTERNAL - The INTERNAL account is provided mainly for backward compatibility with earlier versions of Oracle, but is still used for key functions such as starting up and shutting down the instance.
  • SYS - Automatically created whenever a database is created. Used primarily to administer the data dictionary. This account is granted the DBA role, as well as CONNECT and RESOURCE roles.
  • SYSTEM - Automatically created whenever a database is created. This account is used primarily to create tables and views important to the operation of the RDBMS

Administrative roles

  • DBA
  • OSOPER - Assigned to special accounts that need OS authentication, which can be done only when the database is open; allows users to run commands like STARTUP and SHUTDOWN, and ALTER DATABASE
  • OSDBA - OSOPER plus additional permissions such as CREATE DATABASE or ADMIN OPTION

Oracle instances

An Oracle instances is identified by a SID (system identifier), and is functionality equivalent to a SQL Server database.

(I must credit the following Web sites for much of the previous content, as I certainly did not know much of this until I visited: http://vsbabu.org/, http://www.fredshack.com/, and http://www.rocket99.com/.)

Setting Up Your Oracle Database

Now that we've provided a high-level discussion of Oracle, and some of the differences from SQL Server (and yes, I realize that this is not a comprehensive analysis or comparison - you can find plenty of those elsewhere), let's look at some of the steps you need to take in order to work with Oracle.

1. Install the Oracle database server.  See Oracle for Microsoft Developers, Part I: Installing Oracle 9.2 on Windows Server 2003 for detailed steps on installing Oracle 9.2.

2. Use SQL*Plus and log into the Oracle database server.  I prefer to login as "system" when defining tablespaces, users, etc.

3. Create a new tablespace.  The following script creates a tablespace called "ts_name" at the root of the drive that Oracle is installed on (e.g. C:\), has logging turned on, a default size of 32 MBs that automatically extends to 2 GBs.

create tablespace ts_name
  logging
  datafile '/ts_name.dbf'
  size 32m
  autoextend on
  next 32m maxsize 2048m
  extent management local;

4. Create a new user (or user schema) that has access to this tablespace.  The following script creates a user named "alfred" with a password of "pword".

create user alfred identified by pword;

You can also define the default and temporary tablespace for this uses, as well as the quota.  Note: you can specify a numeric value for the quota (such as 10) or unlimited, which defines an unlimited quota.

create user alfred identified by pword
  default tablespace ts_name temporary tablespace ts_name quota unlimited on ts_name;

Failure to define a quote for your user within the tablespace will prevent the user from actually writing data into the database.  Make sure you don't miss this step!

5. Grant the user privileges, such as creating a session, table, views, etc.

grant create session to alfred;
grant create table to alfred;
grant create view to alfred;
grant create trigger to alfred;
grant create procedure to alfred;
grant create sequence to alfred;
grant create synonym to alfred;

6. Close SQL*Plus, cause you're done!

At this point you should be set!  You've created a tablespace, a user, and given the user the privileges necessary to create tables, procedures, and more!

Realize again that I am not an Oracle DBA, and I would never think about configuring a production environment for Oracle.  The purpose of this blog is to familiarize Microsoft developers with Oracle, as it's very likely you'll have to work with it sooner or later.  The ability to setup and define your development environment should not be underrated and marginalized, as it will not only help you with your delivery, but also make you more marketable!

Best of luck!

posted on Monday, May 28, 2007 7:35:19 AM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback
# Sunday, May 27, 2007

There comes a time in every Microsoft developers life that he/she will have to work with an Oracle database.  I hope that you find this to be a good experience; my experiences have thus far been a mixed bag, mostly because of my own ignorance.  Nevertheless, I've picked up a few things here and there, and figured that it would be worthwhile to post some of the top tips and tricks I've learned over the years.

In this post, I want to discuss how to setup an Oracle database server.  I am going to follow-up with a post on how to create an Oracle database.  I use those terms loosely, because the terminology within the Oracle world is different from the SQL Server world.  I promise I'll do my best to get it right, but chances are I'll make a mistake or two - please feel free to point out my gaffes.

So, without further ado, let's see go through the steps needed to install Oracle 9.2 (sorry, I don't have 10+) on Windows Server 2003 32-bit (note: there are many differences between 32-bit and 64-bit Windows, and my experience has shown that the following steps will not work in 64-bit Windows.  Perhaps I'll follow-up in the future if I figure out how to get it to work ...)

  1. Secure a copy of Oracle 9.2.  I assume that you have a copy available through work.
  2. Start the Oracle Universal Installer.  Click the Next button.


  3. Confirm the installation destination (you'll need at least 3 GBs available for the installation) and click Next.


  4. Select "Oracle9i Database 9.2.0.1.0", and click Next.


  5. Select "Enterprise Edition", and click Next.  (Why?  Well, I don't have any compelling reason here - it's just what I've used to get things working ...)


  6. Select "General Purpose", and click Next.


  7. Leave the Port Number as 2030, and click Next.


  8. Define the Global Database Name.  I choose "orcl", but feel free to choose whatever.  Make sure that the SID is unique - it's probably easiest to make it the same value as the Global Database Name.  Click Next.


  9. Specify the Directory for Database Files.  I choose to leave the default value.  Click Next.


  10. Unless you have a reason to change it, leave the "default character set" selected, and click Next.


  11. On the Summary screen, click Install.  This installation process will take a little while.  Be patience.  Read one of my other posts, while you're waiting.


  12. The next screen to appear is the Database Configuration Assistance.  On this screen, specify the SYS and SYSTEM passwords.  Do NOT click OK yet.


  13. Before you click OK, click the Password Management Button.  Specify passwords for SYS, SYSTEM, and DBSNMP (SCOTT too, if you'd like).


  14. Once you get to the End of Installation, click Exit.


  15. After you click Exit, the Oracle Enterprise Management Console will start.  Check and make sure you can log into your Oracle database server by expanding databases, right-click ORCL (or whatever you called it) and click Connect.  Enter the "system" Username, and change Connect as from "Normal" to "SYSDBA".  Click OK.


  16. If you were able to successfully connect to the Oracle database server, then restart Windows.  There's a number of reasons to do this, including updates to the PATH environment variable.

And that's it!

Now, I realize that this installation procedure pretty much accepts the defaults, and clicks next.  However, at least you have the benefit of knowing that this procedure does work, and will prepare you for the next step: configuring Oracle databases, tablespaces, users, and user access.

Best of luck!

posted on Sunday, May 27, 2007 9:34:04 PM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback