Application lost access of Oracle after character set change - oracle

I changed the character set from we8mswin1252 to al32utf8 in Oracle using these commands.
SHUTDOWN IMMEDIATE
STARTUP RESTRICT
ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;
ALTER DATABASE CHARACTER SET AL32UTF8;
SHUTDOWN IMMEDIATE
STARTUP
Although my character set is changed, I lost the access from my application to all the current databases. I had to create another database to run the application. Is there a solution?

Related

How can I create an Oracle database in docker, using UTF8 as national character set?

I have created a docker container, containing an Oracle 18 XE instance with a container database and a pluggable database. The application I want to test with this pluggable database requires the database to have national character set UTF8. I can not change this, it is just a requirement.
The (empty) database is created and up and running. The character set however is AL16UTF16. I tried several options to change the national character set of both the container database and the pluggable database, all without success.
The procedure I followed, is described here. The docker images I downloaded from github, and the installer for Oracle 18c Express Edition from Oracle.
I tried to add the parameter to the docker run command:
-e ORACLE_NLS_NCHAR_CHARACTERSET=UTF8, without success.
Before creating the docker image, I tried adding the setting NLS_NCHAR_CHARACTERSET=UTF8 to the configuration file oracle-xe-18c.conf, without success.
I tried the instructions from this site, without success. While the database is empty, trying to change the national character set results in the message ORA-12717: Cannot issue ALTER DATABASE NATIONAL CHARACTER SET when NCLOB, NCHAR or NVARCHAR2 data exists. I checked columns affected by the change of national character set with select owner, table_name, column_name from dba_tab_columns where (data_type = 'NCHAR' or data_type = 'NVARCHAR2' or data_type = 'NCLOB') and owner != 'SYS' and owner != 'SYSTEM';, and then a select * on all columns found. They all contained no data.
How can I create an Oracle database in docker, using the national character set UTF8?
Your version of Oracle is 18 which directly supports setting default charset via environment variable. I didn't try it but I guess just calling docker run -e ORACLE_CHARACTERSET=AL32UTF8 ... could be sufficient.
I solved this problem on 11g using ALTER DATABASE CHARACTER SET INTERNAL_USE .... This command must be run on db in restricted mode (see original answer, my application on docker scripts is in comment, it should be applicable to Oracle 18 too).

Import dmp file created in Oracle 11g (WE8ISO8859P1) to Oracle 11g XE database (AL32UTF8)

I am regularly given a dmp file that gets created using oracle v.11g (using the exp utility).
I used to import this file to the Western European edition of Oracle 10g XE.
The import would terminate successfully without warnings but there was an error log (alert_xe.log) that would contstantly increase in size because I was using the the 32 Bit Oracle Database on a 64 Bit Windows OS.
I have now installed 11g XE and I am trying to import the same dmp file but I am seeing the following in the import log file:
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
export client uses WE8ISO8859P1 character set (possible charset conversion)
and the import terminates with warnings as I have a lot of the following errors:
IMP-00019: row rejected due to ORACLE error 12899
IMP-00003: ORACLE error 12899 encountered
ORA-12899: value too large for column XXX (actual: 256, maximum: 255)
I understand that the cause of the problem is that the source database is using byte semantics and my new 11g XE database is using multibyte character set.
I have no control over the source database so I cannot change anything there.
Moreover I cant pre-create the tables with columns definitions using character length semantics over byte semantics (as indicated here for example Character set in Oracle 11g r2 XE) as somethimes the source database schema gets changed (columns might get added) and I am not notified so that breaks the import.
Is there a solution to this problem?
Is there any way to use WE8MSWIN1252 with Oracle 11g XE?
No, unfortunately you can't do it.
As it's stated in Oracle official documentation:
9 Oracle Database XE Character and Language Configurations
Oracle Database XE is available only in Universal character set and language configurations:
The database is created using Unicode(AL32UTF8) character set, which is suitable for global data in any language.
http://docs.oracle.com/cd/E17781_01/install.112/e18803/toc.htm#XEINW138
The only workaround is to preallocate the tables in advanced.
I had the same issue.
When I run this command
imp <username>/<password>#<hostname> file=<filename>.dmp log=<filename>.log
It was showing
import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
export client uses AR8MSWIN1256 character set (possible charset conversion)
IMP-00031: Must specify FULL=Y or provide FROMUSER/TOUSER or TABLES arguments
IMP-00000: Import terminated unsuccessfully
That mean my oracle server is AL32UTF8 character set and export dump file client use AR8MSWIN1256 character set.
So I just changed the oracle character set to AR8MSWIN1256 by using following command.
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
ALTER DATABASE CHARACTER SET INTERNAL_USE AR8ISO8859P6;
SHUTDOWN IMMEDIATE;
STARTUP;
Then run again
imp <username>/<password>#<hostname> file=<filename>.dmp log=<filename>.log FULL=Y
I hope this anwser will help someone
Same problem i was facing to transfer data from oracle 11g to oracle xe version. what steps i have used at that time shown below:
'CONN SYS/(YOUR sys user PASSWORD) AS SYSDBA
SHUTDOWN IMMEDIATE;
STARTUP restrict;
ALTER DATABASE CHARACTER SET INTERNAL_USE WE8MSWIN1252;
SHUTDOWN IMMEDIATE;
STARTUP;'
Once oracle get started try to import your .dmp file after recreating user.

Altering session permanently

Is it possible to alter the session permanently even after i close my oracle sql developer?
An example of the statement that i want to alter:
Alter Session Set Nls_Timestamp_Tz_Format='HH24:MI TZR';
The above statement only allow me to alter the current session and not making it permanently.
Thanks
If you just want to change the default value for SQL Developer, you can do that in the SQL Developer settings. In SQL Developer 3.1 (the same settings exist in earlier versions though the navigation may be slightly different), Tools | Preferences | Database | NLS allows you to specify a Timestamp Format and a Timestamp TZ Format. SQL Developer will then automatically issue the appropriate ALTER SESSION commands for you whenever it creates a new session.
You need to set this in the initialization parameter file to affect the database globally.
Initialization parameters such as Nls_Timestamp_Tz_Format can be set up from three sources:
In a session using the ALTER SESSION SET statement
In client side parameter file init.ora
In server side parameter file spfile
To set default permanently in the db, from the database:-
alter system ... scope=spfile;
then as SYS (so you may need to talk to a DBA), and obviously at an appropriate time! -
shutdown;
startup;
(I know the spfile has been mentioned, but it can all be done from the sqlplus cmdline, at least in 11g.)

Changing Character set to Arabic In Oracle

Kindly guide me how to change the character set to Arabic in Oracle .
please mention the steps that i need to follow, regrading it.
go to start>run type regedit and then look for by pressing h key in keyboard hkey local machine and software and oracl dev home and look for nls_lang change it to AMERICAN_AMERICA.AR8MSWIN1256
Check this link for step by step instructions: http://download.oracle.com/docs/cd/B10501_01/server.920/a96529/ch10.htm#1009904
STARTUP MOUNT;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
ALTER DATABASE CHARACTER SET AR8ISO8859P6;
SHUTDOWN IMMEDIATE; -- or SHUTDOWN NORMAL;
STARTUP;

How to change default nls_date_format for oracle jdbc client

I have defined the global nls_date_format on Oracle 10.2 XE as follows:
alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile;
When connecting on Windows, the clients override it with session specific format, so I need to run this line at the beginning of every session:
alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';
However, I have some custom code that I can't change (jdbc code, using ojdbc14.jar), so I can't execute this line when receiving the connection. Is there a way to change the default value of nls_date_format for all jdbc connections? Perhaps adding something to the connection string, or some environment variable that I can use?
By the way, sqlplus and sqldeveloper also override the server's format with their own, but I found out how to change their defaults, so the problem is only with jdbc connections.
Set nls date format in an after logon trigger
Thanks, that worked for me.
The trigger that I inserted is this:
CREATE OR REPLACE TRIGGER LOGINTRG
AFTER LOGON ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_DATE_FORMAT=''YYYY-MM-DD HH24:MI:SS''';
END LOGINTRG;

Resources