﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Johannes Ahrends' Blog</title>
    <description>&lt;table&gt;
        &lt;tr&gt;
            &lt;td valign="top"&gt;&lt;img height="183" width="139" alt="" src="/Portals/0/Blog/blog-johannes-ahrends.png" /&gt;&lt;/td&gt;
            &lt;td valign="top"&gt;Johannes Ahrends is an Oracle database specialist at Quest Software and a recognized Oracle expert with more than 15 years of experience as an Oracle DBA and consultant. Together with former colleagues he has published two German Oracle books: Oracle9i für den DBA and Oracle 10g für den DBA. Both of them became the most popular Oracle Books in Germany. With this background Johannes has done a large variety of presentations at the German Oracle User Group (DOAG) conferences and local seminars.
            &lt;p&gt;&lt;font color="#003366" size="3"&gt;&lt;strong&gt;Recent postings:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
&lt;/table&gt;</description>
    <link>http://www.toadworld.com/BLOGS/tabid/67/BlogId/28/Default.aspx</link>
    <language>en-US</language>
    <managingEditor>Johannes Ahrends</managingEditor>
    <webMaster>webmaster@toadworld.com</webMaster>
    <pubDate>Fri, 19 Mar 2010 04:26:41 GMT</pubDate>
    <lastBuildDate>Fri, 19 Mar 2010 04:26:41 GMT</lastBuildDate>
    <docs>http://backend.userland.com/rss</docs>
    <generator>Blog RSS Generator Version 3.2.0.15477</generator>
    <item>
      <title>Unicode Migration</title>
      <description>&lt;div&gt;Migrating to a database that supports Unicode is a challenge. You are safe if you are currently using  US7ASCII for you Oracle database because Oracle provides a mechanism with ALTER DATABASE SET CHARACTERSET UTF8 which allows you by just bouncing the database to switch to this new character set. But what if you are currently on a different character set? In Europe we have a bunch of WE8 (Western European) or EE8 (Eastern European) character sets and as they are not a strict subset of Unicode the ALTER Database does not work. So the only chance is to export the whole database, create a new one (with UTF8 or similar) and import it again.&lt;/div&gt;
&lt;div&gt;Is it that easy? No! The reason is that in most databases the so called length semantics hasn’t been used while creating a table. Since Oracle9i the correct syntax for creating is:&lt;/div&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px"&gt;
&lt;pre&gt;CREATE TABLE test1&lt;br /&gt;(custid   NUMBER(10),&lt;br /&gt;lastname VARCHAR2(6 CHAR))&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;div&gt;Have you used this syntax? No of course not! We all used the old version:&lt;/div&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px"&gt;
&lt;pre&gt;CREATE TABLE test1&lt;br /&gt;(custid   NUMBER(10),&lt;br /&gt;lastname VARCHAR2(6))&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;div&gt;
&lt;p&gt;But what is the difference? The default behavior for an Oracle database is to use “BYTE” as length semantic. And this can cause huge problems while migrating to Unicode.&lt;/p&gt;
&lt;p&gt;Let’s assume your current database is working with WE8MSWIN1252 (common on western European Windows Databases). Entering the following name into the customer table is safe:&lt;/p&gt;
&lt;/div&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px"&gt;
&lt;pre&gt;INSERT INTO customer (custid, lastname)&lt;br /&gt;VALUES&lt;br /&gt;(1,’Müller’);&lt;br /&gt;COMMIT;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;div&gt;If you try to enter the same row in an Oracle database with AL32UTF8 you get the following error message:&lt;/div&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px"&gt;
&lt;pre&gt;ERROR at line 2:&lt;br /&gt;ORA-12899: value too large for column "DEMO"."TEST1"."LASTNAME" (actual: 7, maximum: 6)&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;div&gt;
&lt;p&gt;The reason is that a German umlaut takes two bytes in Unicode as well as most special characters for other languages.&lt;/p&gt;
&lt;p&gt;When using Oracle export/import or datapump the situation doesn’t change because both utilities are using the exported format while importing into an new database.&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;The only chance is to first create the objects and then do the import.&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;Toad has a very nice switch under options -&gt; data types which is called “Include Byte/Char spec when creating DDL scripts from 9i databases”. This behavior is not limited to 9i but all existing Oracle versions you can switch off the “BYTE or CHAR” specification for all scripts.&lt;/p&gt;
&lt;p&gt;Now you can generate the schema script (under menu export) for all schemas you want to recreate and execute a user export or full export of the database.&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;On your target you first create the user (maybe with CREATE LIKE…) using Toad and load your generated schema script. Before you execute it ,please add one command to the script:&lt;/div&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px"&gt;
&lt;pre&gt;ALTER SESSION SET NLS_LENGTH_SEMANTICS = 'CHAR';&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;div&gt;
&lt;p&gt;This will switch the actual session into a mode where the default length semantic is now CHAR instead of BYTE. This works for a session as well as for the database but there are several known bugs if you switch it for the database so better only use it for the actual session.&lt;/p&gt;
&lt;p&gt;The test table is now created like:&lt;/p&gt;
&lt;/div&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px"&gt;
&lt;pre&gt;CREATE TABLE test1&lt;br /&gt;(custid   NUMBER(10),&lt;br /&gt;lastname VARCHAR2(6 CHAR));&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;div&gt;which allows you to insert the lastname “Müller” now.&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;After all objects are successfully created you can run the import for the table data but don’t forget to switch on “IGNORE ERRORS” as the “CREATE TABLE” scripts are included in the export file.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/div&gt;</description>
      <link>http://www.toadworld.com/BLOGS/tabid/67/EntryID/306/Default.aspx</link>
      <author>Johannes Ahrends</author>
      <comments>http://www.toadworld.com/BLOGS/tabid/67/EntryID/306/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.toadworld.com/Default.aspx?tabid=67&amp;EntryID=306</guid>
      <pubDate>Mon, 03 Nov 2008 17:24:00 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.toadworld.com/DesktopModules/Blog/Trackback.aspx?id=306</trackback:ping>
    </item>
  </channel>
</rss>