My blog has moved!

You should be automatically redirected in 5 seconds. If not, visit
http://www.oraexplorer.com
and update your bookmarks.

Tuesday, June 24, 2008

A Million Thanks to Mom

My kid found this e-card on the Hallmark web site for the Mother's day. We really like the voices of hoops and yoyo - two cartoon characters. Since the card says, "A Million Thanks to Mom", we initially thought it'd probably be done by one million. But apparently it is not. So for fun, we let it run, and it keeps going and going. We've decided to let it continue to see how far it can go. Please note that it takes about one whole day to reach 1M on my desktop machine.




If you want to try out, here is the link, select "A Million Thanks for Mom".

Let me know how far you make it.

[Updated 6/3] Reached 3 millions and still going...
 


[Updated 6/4] Wow 4 millions now. Umm.. I don't know whether or not I should stop it, or let it continue.

 

[Updated 6/10] Now I'm reaching the 10 million “Thanks”. I can’t believe this thing can go on and on. I'm tempted to let it continue and see how far it can go.

[Updated 6/20] After about twenty days of this journey, I just reached 20 million Thanks. Wow..

My daughter urged me to continue. Well, let’s do it.

ThankYou20M_0620

[Update 6/23] Somehow, my XP desktop was rebooted unexpectedly over weekend :-( Well, I guess my 20-day “FUN” trip has to come to the end. It is sad but I feel relief because finally I can use my computer without annoying noises.

Sunday, June 15, 2008

Oracle SQL Developer Migration Workbench

The Oracle SQL developer is not only a great tool for SQL development, with its migration workbench, it is an excellent tool for database migration. Did I also mention it is free?

To get it started, you will need to download the latest version of the tool which is version 1.5.1. Also it is recommended to install the latest updates. The current release of update as of 6/15 is 1.5.1.54.40.

Next, you will need to create a repository. An database account, which has CREATE SESSION, RESOURCE, and CREATE VIEW must be created first. Then logon into SQL Developer as that account. From the tool, create a repository from Migration menu > Repository Management > Create Repository. This process creates a bunch of MD* and MIGR* tables and packages.

To connect to other non-Oracle databases, you will need to create connections through provided JDBC drivers. If somehow, your SQL Developer does not show these 3-rd party connection tabs, you will have to configure it. Instruction is clearly documented on Oracle site here.

image

In my case, I migrate one of our legacy applications on MS SQL to Oracle. Unfortunately this application contains column name named “rowid”, which is Oracle’s reserved word, in most of tables. The tool has a mechanism to append a suffix “_” (with no quotes) if it encounters these reserved words. So “rowid” will be converted to “rowid_”. To see the list of all reserved words, you can just query “KEYWORD” column in MIGRATION_RESERVEDW_WORDS table under the repository schema. Unfortunately, the “rowid” is not really in this table, I have to insert this manually. I added a keyword “privilege” as well because, again, there is a column named “privilege” used in application.

insert into migration_reserved_words values ('rowid');
insert into migration_reserved_words values ('privilege');
I encountered a bug (which Turloch O'Tierney pointed out - thanks) when using version 1.5.1 without the latest patch. In the function “first_char_check” under MIGRATION_TRANSFER package, a number “4” is missing. The impact of this is that If the column name is numeric prefix, for example, 3Q2008, a letter “A” will be prefixed into it to be “A3Q2008”. But due to this bug, it won’t do it with, for example, 4Q2008, resulting in a failure when trying to create table. With the latest patch, it seems like it was fixed already because I now see number 4.

v_allowed := C_DISALLOWED_CHARS || '012356789_$';

The process of migration is straight-forward. You will start with capture then convert. You can capture and convert the whole database at once. But I would not recommend that because if error is encountered, it might be difficult to troubleshoot.

You can just capture only the table first, this will create a converted script. Before running it, please inspect it first and comment un-needed sections especially CREATE default USER syntax and CONNECT using default user. By running the converted script, it will create the definitions of tables, sequences, triggers and constraints. If there is no error, then you can run to move data.

Once data is there, repeat the steps with stored procedures and views. Obviously, you will just need to run the converted script – there is no need for data movement.

Monday, June 9, 2008

Statistic Calculation - DBMS_STAT_FUNCS

Currently I'm working on a project dealing with lot of statistic calculations particularly that of quartiles. First, I have no idea what it is. Thanks to Wiki for explanation. Now the tough part is to do the actual calculation. Fortunately, Oracle provides DBMS_STAT_FUNCS which is exactly what I'm looking for.

List of available calculations -

TYPE summaryType IS RECORD (
count NUMBER,
min NUMBER,
max NUMBER,
range NUMBER,
mean NUMBER,
cmode num_table,
variance NUMBER,
stddev NUMBER,
quantile_5 NUMBER,
quantile_25 NUMBER,
median NUMBER,
quantile_75 NUMBER,
quantile_95 NUMBER,
plus_x_sigma NUMBER,
minus_x_sigma NUMBER,
extreme_values num_table,
top_5_values n_arr,
bottom_5_values n_arr);
Sample -
set serveroutput on;
DECLARE
sfsumtype dbms_stat_funcs.summaryType;
BEGIN
dbms_stat_funcs.summary(p_ownername=>'SCHEMA_NAME',
p_tablename=>'TABLE_NAME',
p_columnname=>'COLUMN_NAME',
s=>sfsumtype);
dbms_output.put_line('Quantile 5 => ' || sfsumtype.quantile_5);
dbms_output.put_line('Quantile 25 => ' || sfsumtype.quantile_25);
dbms_output.put_line('Median => ' || sfsumtype.median);
dbms_output.put_line('Quantile 75 => ' || sfsumtype.quantile_75);
dbms_output.put_line('Quantile 95 => ' || sfsumtype.quantile_95);
END;
/