{"id":1065,"date":"2014-09-10T22:13:46","date_gmt":"2014-09-10T16:43:46","guid":{"rendered":"http:\/\/www.allerin.com\/blog\/?p=1065"},"modified":"2016-05-12T15:14:35","modified_gmt":"2016-05-12T09:44:35","slug":"oracle-charset-issues-with-unicode-data-storage-in-rails","status":"publish","type":"post","link":"https:\/\/www.allerin.com\/blog\/oracle-charset-issues-with-unicode-data-storage-in-rails\/","title":{"rendered":"Oracle charset &#8211; Issues with Unicode data storage in Rails"},"content":{"rendered":"<p>Working with Oracle database supported application, which we want to internationalize, and then\u00a0 \u2018charset\u2019 is crucial factor to provide Unicode storage ability.<\/p>\n<p>If we are going to internationalize a new project then we can start by creating a Unicode supported database.<\/p>\n<p>For example, we can select AL32UTF8 charset while creating the database.<\/p>\n<p>If we are going to support internationalization on an existing database then, we need to change the charset of database.<\/p>\n<p>There are two ways of changing charset of a database.<\/p>\n<p>Either you can directly alter the charset of existing database or by performing full import export.<\/p>\n<p>First you need to know the current charset of database<\/p>\n<p>&lt;pre&gt;<\/p>\n<p>SELECT value$ FROM sys.props$ WHERE name = \u2018NLS_CHARACTERSET\u2019 ;<\/p>\n<p>&lt;\/pre&gt;<\/p>\n<p>This query will tell you current charset of your database.<\/p>\n<p>Other Oracle database NLS parameters can be known by following query<\/p>\n<p>&lt;pre&gt;<\/p>\n<p>SELECT * FROM NLS_DATABASE_PARAMETERS;<\/p>\n<p>&lt;\/pre&gt;<\/p>\n<p>To alter charset of database directly, the target charset should be a strict superset of current database charset.<\/p>\n<p>You can alter charset with following steps:<\/p>\n<p>1.\u00a0 Shut down the database, using either a SHUTDOWN IMMEDIATE or a SHUTDOWN NORMAL statement.<\/p>\n<p>2.\u00a0 Do a full backup of the database, because the CSALTER script cannot be rolled back.<\/p>\n<p>3.\u00a0 Start up the database.<\/p>\n<p>4.\u00a0 Run the Database Character Set Scanner utility.<\/p>\n<p>&lt;pre&gt;<\/p>\n<p>CSSCAN \/AS SYSDBA FULL=Y&#8230;<\/p>\n<p>&lt;\/pre&gt;<\/p>\n<p>5.\u00a0 Run the CSALTER script.<\/p>\n<p>&lt;pre&gt;<\/p>\n<p>@@CSALTER.PLB<\/p>\n<p>SHUTDOWN IMMEDIATE; &#8212; or SHUTDOWN NORMAL;<\/p>\n<p>STARTUP;<\/p>\n<p>&lt;\/pre&gt;<\/p>\n<p>The other way is quite safer and recommended.<\/p>\n<p>Following are the steps to export and import data in oracle 11g R2:<\/p>\n<p>To export database:<\/p>\n<p>1.\u00a0 Start SqlDeveloper.<\/p>\n<p>2.\u00a0 Create connections for source and destination. (Note: Use system user)<\/p>\n<p>3.\u00a0 From View menu select DBA. DBA pane will appear.<\/p>\n<p>4.\u00a0 Now in DBA pane, add connections.<\/p>\n<p>5.\u00a0 Click and expand the source connection, then right-click on &#8216;Data Pump&#8217;, and then click on &#8216;Data Pump Export Wizard.&#8217; Export Wizard will start.<\/p>\n<p>6.\u00a0 In &#8216;Data Pump Export Wizard,&#8217; select Schema option in Types to be Exported in &#8216;Data Pump&#8217; and click on &#8216;Next.&#8217;<\/p>\n<p>7.\u00a0 Select(double click) a schema that you want to export and click &#8216;Next.&#8217;<\/p>\n<p>8.\u00a0 Skip the step Filter and click &#8216;Next.&#8217;<\/p>\n<p>9.\u00a0 Now, click on &#8216;More,&#8217; now select Type as &#8216;ALL OBJECTS&#8217; and click on &#8216;Lookup.&#8217; All the objects are displayed.<\/p>\n<p>10. From the interface select and add objects to include for export and click &#8216;Next.&#8217; To include all objects just click on down double-arrow button.<\/p>\n<p>11. Specify the name for log file or just leave the default and click &#8216;Next.&#8217;<\/p>\n<p>12. In &#8216;Choose Output Files&#8217; section, specify the File Names (For example exportdata.dmp), choose an appropriate option if file already exists, and click &#8216;Next.&#8217;<\/p>\n<p>13. Now leave the default settings and click &#8216;Next.&#8217;<\/p>\n<p>14. In &#8216;Summary&#8217; section, verify whether the desired schema is included, and finally click &#8216;Finish.&#8217; You will see this job and its status in &#8216;Data Pump&#8217; &gt; &#8216;Export Jobs&#8217; of DBA pane.<\/p>\n<p>15. Now, copy this file from the source machine to the destination machine.<\/p>\n<p>For importing database:<\/p>\n<p>1.\u00a0 Start SqlDeveloper and open &#8216;Data Pump Import Wizard.&#8217;<\/p>\n<p>2.\u00a0 In Wizard, select Connection where you want to import(destination system).<\/p>\n<p>3.\u00a0 Select Schema and specify file Name. In this case, file is exportdata.dmp and then click &#8216;Next.&#8217;<\/p>\n<p>4.\u00a0 Now, include the schema that you want to import from &#8216;Available Source Schemas&#8217; to &#8216;Selected Source Schemas&#8217; and click &#8216;Next.&#8217;<\/p>\n<p>5.\u00a0 Skip Remapping step by clicking &#8216;Next.&#8217;<\/p>\n<p>6.\u00a0 In Options step, select appropriate options for &#8216;Action On Table&#8217; if Table Exists and click &#8216;Next.&#8217;<\/p>\n<p>7.\u00a0 Click &#8216;Next&#8217; and finally Click &#8216;Finish.&#8217;<\/p>\n<p>Your database will be imported as per selected options and schemas.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Working with Oracle database supported application, which we want to internationalize, and then\u00a0 \u2018charset\u2019 is crucial factor to provide Unicode storage ability. If we are going to internationalize a new&#8230;<\/p>\n","protected":false},"author":9192191,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[3],"tags":[],"class_list":["post-1065","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/posts\/1065","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/users\/9192191"}],"replies":[{"embeddable":true,"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/comments?post=1065"}],"version-history":[{"count":1,"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/posts\/1065\/revisions"}],"predecessor-version":[{"id":1066,"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/posts\/1065\/revisions\/1066"}],"wp:attachment":[{"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/media?parent=1065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/categories?post=1065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.allerin.com\/blog\/wp-json\/wp\/v2\/tags?post=1065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}