Nls_database_parameters- nls_length_semantics Help!

Hi all!
I have to create a database with the parameter nls_length_semantics set to char but I don't know how to do it!
In a new machine, where was installed only the oracle client(10), I install a new database software (10g), during the installation process I was unable to select the character set.
Then I install the first instance and select AL32utf8 as character set and select length semantics= char.
But the select * from nls_database_parameters shows nls_length_semantics=byte ko
and
select * from nls_instance_parameters shows nls_length_semantics= char ok
how can I do to set both with nls_length_semantics= char?
Yes I will reinstall the database but I do not understand what was wrong?
Thank you for help
Mario

Execute:
ALTER SYSTEM SET NLS_LENGTH_SEMANTICS=CHAR scope=both;
And restart the database - despite scope is both, only after restart it will be changed.
But there is a Bug 1488174 - and this alter system depending on version can have no effect even after restart. The only way to modify is then to change init.ora (create from spfile pfile, change parameter, startup and create spfile from pfile, restart once more database and start with spfile).
And by Oracle recomendation:
+Do NOT set the NLS_LENGTH_SEMANTICS=CHAR during database creation, create the database with NLS_LENGTH_SEMANTICS=BYTE (or not set) and set NLS_LENGTH_SEMANTICS=CHAR after the database creation.+
For more details reffer to metalink note 144808.1

Similar Messages

  • Alter system set nls_length_semantics

    Hi all,
    my question concerns the scope in the change of NLS_LENGTH_SEMANTICS can be performed.
    The 10gR2 documentation only the
    "Modifiable      ALTER SESSION"
    But what about altering the system and making your own setting to default for all sessions? With which scope?
    I tried
    alter system set nls_length_semantics='CHAR';
    alter system set nls_length_semantics='CHAR' scope=spfile;
    alter system set nls_length_semantics='CHAR' scope=both;
    None had really any effect. Do I have to bounce the database?

    Hello,
    Do I have to bounce the database?Yes, you have to shutdown and startup the database.
    Else the NLS_LENGTH_SEMANTICS change won't be effective.
    You may have more details on the following thread:
    nls_database_parameters->nls_length_semantics Help!
    There's also an interesting Note from MOS:
    Examples and limits of BYTE and CHAR semantics usage (NLS_LENGTH_SEMANTICS) [ID 144808.1]They give many information about NLS_LENGTH_SEMANTICS and the following Bug:
    Bug 1488174
    Problem: ALTER SYSTEM does not change the setting of NLS_LENGTH_SEMANTICS for the current and new (!) sessions.
    Workaround: Don't use ALTER SYSTEM SET NLS_LENGTH_SEMANTICS scope=both; but set NLS_LENGTH_SEMANTICS as a init.ora parameter or issue ALTER SYSTEM SET NLS_LENGTH_SEMANTICS=CHAR scope=spfile; and bounce the database.Hope this help.
    Best regards,
    Jean-Valentin
    Edited by: Lubiez Jean-Valentin on May 27, 2010 2:06 PM

  • Need help on changing parameter NLS_LENGTH_SEMANTICS

    hi All,
    Oracle is 11.2.0.1.0
    Initially our db parameter NLS_LENGTH_SEMANTICS='CHAR' for one table I am getting error
    like
    ORA-01450: maximum key length (6398) exceeded Missing Resource String.
    I changed it NLS_LENGTH_SEMANTICS='BYTE'
    now I am able to create that table
    Is there any side effect if I am changing NLS_LENGTH_SEMANTICS from CHAR to BYTE
    like
    ALTER SYSTEM SET NLS_LENGTH_SEMANTICS='BYTE' scope=both;
    Please help me .
    Thanks In advance.

    Hi;
    Please check below notes which could be helpful to get your answer
    SCRIPT: Changing columns to CHAR length semantics ( NLS_LENGTH_SEMANTICS ) [ID 313175.1]
    Examples and limits of BYTE and CHAR semantics usage (NLS_LENGTH_SEMANTICS) [ID 144808.1]
    Changing NLS_Length_semantics from BYTE to CHAR [ID 974744.1]
    Can The Parameter NLS_LENGTH_SEMANTICS Be Changed From BYTE To CHAR? [ID 906801.1]
    Regard
    Helios

  • Help During Installation

    Hi all,
    I am a first time user of APEX and tried to install it with ORACLE 10.2. I have followed the steps during installation
    a: create the two tablespaces (user and files) for apex to use.
    b. run apexins.sql however i get this error:
    wwv_flow_api.create_list_item (
    ERROR at line 112:
    ORA-06550: line 112, column 1:
    PLS-00306: wrong number or types of arguments in call to 'CREATE_LIST_ITEM'
    ORA-06550: line 112, column 1:
    PL/SQL: Statement ignored
    Any help will be appreciated
    Cheers,
    Joon Daroy

    Joon,
    This one is a little baffling to me. In essence, this is saying that the procedure specification for wwv_flow_api.create_list_item is not what is expected during installation of the internal (i.e., Builder) applications of APEX.
    I'm not aware of any other customer encountering this with APEX 3.0. That isn't to say it's your fault, I just have not seen it before.
    1) What is your exact database version (10.2.0.?)
    2) What platform is this on?
    3) What is the result of the query: select value from nls_database_parameters where parameter = 'NLS_LENGTH_SEMANTICS'
    Joel

  • Help imigrating data from 9i database to 10g express edition

    hi all ,
    i am trying to import a *.dmp file from 9i to 10g express edition
    then problem is that i keep getting during import is
    imp-11119
    imp-11113
    ora-12899
    the data being imported is not english , it appears that there is a problem
    with importing the data
    can someone please help me plz

    i am sorry the errors are
    imp-00019
    imp-00003
    ora-12899
    i am using database 10g express universal edition
    in 9i
    select * from nls_database_parameters;
    PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET AR8MSWIN1256
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    PARAMETER VALUE
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_RDBMS_VERSION 9.0.1.1.1
    but in 10g express universal edition
    select * from nls_database_parameters;
    PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CURRENCY $
    NLS_ISO_CURRENCY AMERICA
    NLS_NUMERIC_CHARACTERS .,
    NLS_CHARACTERSET AL32UTF8
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_SORT BINARY
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    PARAMETER VALUE
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY $
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_RDBMS_VERSION 10.2.0.1.0

  • Arabic Character set conversion-help needed

    We have our main database running in 10g (Solaris o/s) & planning to move these to RAC 11g.
    One of our old oracle DB(8.0.5)/solaris, which is not used till recently need to upgrade to 10g Rel2.
    I know Supported direct upgrade 8.0.6/8.1.7/9i -> 10g
    Current DB: 8.0.5 (Character Set: AR8ISO8859P6)
    Target DB : 10g Rel 2 (Character Set: AR8MSWIN1256)
    I am thinking to go the following way by using exp/imp
    8.0.5(AR8ISO8859P6) -> 8.1.7(AR8ISO8859P6) -> 10G(AR8MSWIN1256)
    OR
    8.0.5(AR8ISO8859P6) -> 8.1.7(AR8MSWIN1256) -> 10G(AR8MSWIN1256)
    please advice
    thanks

    (1) At source db 8.0.5 (solaris)
    PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-YY
    NLS_DATE_LANGUAGE AMERICAN
    NLS_CHARACTERSET AR8ISO8859P6
    NLS_SORT BINARY
    NLS_NCHAR_CHARACTERSE T AR8ISO8859P6
    $set NLS_LANG=AMERICAN_AMERICA.AR8ISO8859P6
    $exp sys/dba file=full251109.dmp full=y
    (2):>> At target db 10g R2 (solaris)
    PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD-MON-RRRR
    NLS_DATE_LANGUAGE AMERICAN
    NLS_CHARACTERSET AR8ISO8859P6
    NLS_SORT BINARY
    NLS_NCHAR_CHARACTERSET UTF8
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    $export NLS_LANG=AMERICAN_AMERICA.AR8ISO8859P6
    $imp testdba/testdba file=full251105.dmp fromuser=PROFINAL touser=PROFINAL
    *$csscan testdba/testdba FULL=Y FROMCHAR=AR8ISO8859P6 TOCHAR=AR8ISO8859P6 LOG=P6check CAPTURE=Y ARRAY=100000 PROCESS=2*
    There is EXCEPTIONAL DATA in .err file+
    clients accessing 8.0.5 dataabase uses characterset AR8IS08859P6, which is SAME as 8.0.5 database
    -CSSCAN result->>[Database Scan Parameters]
    Parameter Value
    CSSCAN Version v2.1
    Instance Name MIG1
    Database Version 10.2.0.1.0
    Scan type Full database
    Scan CHAR data? YES
    Database character set AR8ISO8859P6
    FROMCHAR AR8ISO8859P6
    TOCHAR AR8ISO8859P6
    Scan NCHAR data? NO
    Array fetch buffer size 100000
    Number of processes 2
    Capture convertible data? YES
    [Scan Summary]
    Some character type data in the data dictionary are not convertible to the new
    haracter set Some character type application data are not convertible to the new characters
    [Data Dictionary Conversion Summary]
    Datatype Changeless Convertible Truncation Lossy
    VARCHAR2 2,235,403 0 0 *1,492*
    CHAR 1,097 0 0 0
    LONG 155,188 0 0 6
    CLOB 24,643 0 0 0
    VARRAY 21,352 0 0 0
    Total 2,437,683 0 0 1,498
    Total in percentage 99.939% 0.000% 0.000% 0.061%
    The data dictionary can not be safely migrated using the CSALTER script
    [Application Data Conversion Summary]
    Datatype Changeless Convertible Truncation Lossy
    VARCHAR2 16,986,594 0 0 *1,240,383*
    CHAR 164,114 0 0 0
    LONG 7 0 0 0
    CLOB 1 0 0 0
    VARRAY 1,436 0 0 0
    Total in percentage 93.256% 0.000% 0.000%
    6.744%
    [Distribution of Convertible, Truncated and Lossy Data by Table]
    USER.TABLE Convertible Truncation Lossy
    PROFINAL.BASE_MASTER_DATAS 0 0 *362,003*
    PROFINAL.CODE_ALLOW 0 0 *53*
    PROFINAL.CODE_ALLOWANCE_TYPES 0 0 *1*
    PROFINAL.CODE_BONUS_TYPES 0 0 *2*
    PROFINAL.CODE_BRANCHES 0 0 *2*
    PROFINAL.CODE_CERTIFICATES 0 0 *94*
    Kindly help,,,
    Edited by: userR12 on Nov 25, 2009 1:43 AM
    Edited by: userR12 on Nov 25, 2009 1:52 AM

  • [HELP!] perl and unicode are not working

    I have a database that I know supports Unicode, I'm trying to read/write data using perl and I'm pulling my hair out! I have a table populated with some Unicode characters that I inserted using TOAD and this sql statement:
    insert into jay_test values (-101, 'Τη γλώσσα μου έδωσ');
    When I look at the data in TOAD everything looks great, when I read the data out using .NET it works great, when I read it out using PERL the result if a bunch of question marks.
    Here is the code:
    #!/usr/bin/perl -w
    <%
    use utf8;
    use DBD::Oracle;
    $Response->AddHeader("Content-Type","text/html; charset=utf-8;");
    my $dbh2 = DBI->connect($db, $user, $password, {AutoCommit => 1});
    my $x = $dbh2->ora_can_unicode();
    my $sth = $dbh2->prepare("SELECT i, j from jay_test order by i desc");
    $sth->execute();
    while (my ($i, $j) = $sth->fetchrow_array()) {
         debug("i = $i, j = $j");
         $html .= qq{
              <tr>
                   <td>$i</td>
                   <td>$j</td>
              </tr>
    The result is this:
    -101      ?? ?????? ??? ????
    As a note: the line "$dbh2->ora_can_unicode();" returns a value of 3, which means that Unicode should be fully supported.
    Anyone who can point me in the right direction will be my savior! Thanks in advance

    The OS is Red Hat Enterprise Linux Server release 5.4 (Tikanga)
    The Kernel is 2.6.18
    Database is 10g
    Toad is 10.1.1.8
    Here are the parameters that PERL is seeing:
    my $params = $dbh2->ora_nls_parameters();
    print_r($params); return;
    [Hash] {
         NLS_CALENDAR => GREGORIAN
         NLS_CHARACTERSET => AL32UTF8
         NLS_COMP => BINARY
         NLS_CURRENCY => $
         NLS_DATE_FORMAT => DD-MON-RR
         NLS_DATE_LANGUAGE => AMERICAN
         NLS_DUAL_CURRENCY => $
         NLS_ISO_CURRENCY => AMERICA
         NLS_LANGUAGE => AMERICAN
         NLS_LENGTH_SEMANTICS => BYTE
         NLS_NCHAR_CHARACTERSET => AL16UTF16
         NLS_NCHAR_CONV_EXCP => FALSE
         NLS_NUMERIC_CHARACTERS => .,
         NLS_SORT => BINARY
         NLS_TERRITORY => AMERICA
         NLS_TIMESTAMP_FORMAT => DD-MON-RR HH.MI.SSXFF AM
         NLS_TIMESTAMP_TZ_FORMAT => DD-MON-RR HH.MI.SSXFF AM TZR
         NLS_TIME_FORMAT => HH.MI.SSXFF AM
         NLS_TIME_TZ_FORMAT => HH.MI.SSXFF AM TZR
    Do i need to issue a PERL command to change one of these NLS params?
    I appreciate the help everyone, this issue is killing me!

  • NLS_LENGTH_SEMANTICS  best practice

    Hello,
    Is it better to be CHAR or BYTE (default value) on a routine basis? What is the guideline on this?
    Thanks.

    Pl see
    http://docs.oracle.com/cd/E11882_01/server.112/e10729/ch3globenv.htm#NLSPG235
    NLS_LENGTH_SEMANTICS settings
    Need help on changing parameter NLS_LENGTH_SEMANTICS
    HTH
    Srini

  • Unable to change NLS_LENGTH_SEMANTICS

    I am currently trying to run a UTF8 enabled application on a Oracle 11.2.0.1.0 database, and have been having trouble storing some characters into the DB. I have been advised by the application support that the product can definitely do store them, and that I must set the NLS_LENGTH_SEMANTICS parameter to CHAR using the following statement;
    ALTER SYSTEM SET NLS_LENGTH_SEMANTICS=CHAR SCOPE=BOTH;
    However after logging into the target database as the "systems" user and running this statement, which runs successfully, querying the "v$nls_parameters" still shows that it is set to "BYTE". I have tried then creating a new database and setting this value to CHAR in the advanced settings, but still to no avail.
    However after googling this and reading several articles I have began to notice some other strange behaviour. The first thing i noticed was the "SPFILE{dbname}.ORA" file contains the right value i.e;
    *.nls_length_semantics='CHAR'
    The second thing that I noticed was that running the "v$nls_parameters" query in SQL Developer produced a different result to the one produced by SQL Plus (See below) even though exactly the same user in the same database is being used. In SQL developer the following query "select * from v$nls_parameters where Parameter = 'NLS_LENGTH_SEMANTICS';" produces;
    PARAMETER VALUE
    NLS_LENGTH_SEMANTICS BYTE
    1 rows selected
    Where as in SQLPLUS this query produces;
    SQL> select * from v$nls_parameters where Parameter = 'NLS_LENGTH_SEMANTICS';
    PARAMETER
    VALUE
    NLS_LENGTH_SEMANTICS
    CHAR
    Can anyone provide any insight as to what could be the problem with my oracle database setup, as the application developers are adamant that UTF8 chars are supported and the only difference they can see between my setup (which doesnt work) and theirs (which does work) is the value of this parameter. Details of my system are;
    OS: Windows 7 x64
    SQL Developer: 2.1.0.63
    DATABASE: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE     11.2.0.1.0     Production
    TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production

    Forum for NLS / Globalization Support discussions:
    Globalization Support
    user10600690 wrote:
    I am currently trying to run a UTF8 enabled application on a Oracle 11.2.0.1.0 database, Is this database created with db charset of AL32UTF8?
    and have been having trouble storing some characters into the DB. What kind of trouble?
    ALTER SYSTEM SET NLS_LENGTH_SEMANTICS=CHAR SCOPE=BOTH;
    However after logging into the target database as the "systems" user and running this statement, which runs successfully, querying the "v$nls_parameters" still shows that it is set to "BYTE". I have tried then creating a new database and setting this value to CHAR in the advanced settings, but still to no avail. You've changed one parameter and looked at another.
    There are different "levels" in what you wrote in the previous quote. Take a look at the dictionary views (http://download.oracle.com/docs/cd/E11882_01/server.112/e10729/ch3globenv.htm#i1006415)
    NLS_SESSION_PARAMETERS (compare to v$nls_parameters, on which the view is based)
    NLS_INSTANCE_PARAMETERS (alter system set nls...)
    NLS_DATABASE_PARAMETERS (creating a new database...)
    You may need to bounce the instance for the setting to have any effect (even with scope=both) for new sessions. At least I think that was the case in some previous release.
    Note that I do not think you can (or, at least, should) create a database with semantics=char. The "advcanced settings" probably referred to instance parameters.
    The first thing i noticed was the "SPFILE{dbname}.ORA" file contains the right value i.e;
    *.nls_length_semantics='CHAR'Yes, the instance level view should agree.
    >
    The second thing that I noticed was that running the "v$nls_parameters" query in SQL Developer produced a different result to the one produced by SQL Plus Could be different client config/environment settings affecting session parameters. Compare with session level view.

  • Change NLS_LENGTH_SEMANTICS from BYTE to CHAR on Oracle 9i2 problem!

    Hi,
    I have created a new database on Oracle 9i 2, I did not find the correct pfile parameter for the NLS_LENGTH_SEMANTICS setting.
    So have created a standart UTF8 database and now I am trying to change the standard NLS_LENGTH_SEMANTICS=BYTE to CHAR. When I execute the following command in SQL PLUS "ALTER SYSTEM SET NLS_LENGTH_SEMANTICS=CHAR SCOPE=BOTH"
    The system is tells me that command is successfully executed.
    But when I look at the NLS_DATABASE_PARAMETERS table I do not see any change for the NLS_LENGTH_SEMANTICS parameter.
    I have also restarted the instance but still everything is the same as it was before.
    Do you know what I am doing wrong?
    Regards
    RobH

    Hi,
    Yeah you are right, the nls_session_parameters "NLS_LENGTH_SEMANTICS" for the app user is set to CHAR.
    This means that NLS_DATABASE_PARAMETERS is from the SYS or SYSTEM user view?
    Thanks a lot
    Regards
    RobH

  • Setting NLS_LENGTH_SEMANTICS for a Module or session

    Hi,
    We have a DW loading data from three source databases.
    One of the source databases has started using UTF-8, which entails NLS_LENGTH_SEMANTICS = CHAR.
    Another source database will follow later this year.
    The third one is Oracle Applications, which (for the time being) uses WE8ISO8859P1 and BYTE.
    The DW uses WE8ISO8859P1/BYTE, but we have started thinking about changing to UTF-8/CHAR.
    I have two questions about this:
    1. Assuming we recreate all DW tables with the new settings, how will this impact the loading process from the source databases still using WE8ISO8859P1/BYTE? Will the OWB mapping packages transparently read the (packed) source bytes into the (sparse) target characters? Will any necessary character set conversions be done transparently as well?
    2. Assuming we postpone the change to UTF-8 in the DW + want to limit the CHAR implementation to the DW tables receiving data from the CHAR source databases, is it possible to make OWB deploy only the above-mentioned tables as CHAR? I can't find any way to specify CHAR explicitly in OWB. Is it possible to change the session parameter NLS_LENGTH_SEMANTICS dynamically to CHAR in the deployment session?
    Regards,
    Kai Quale
    University of Oslo

    NLS_DATABASE_PARAMETERS contains parameters that have been used at database creation time and is not updated according to
    Re: NLS_DATABASE_PARAMETERS table not showing changes This is IMHO not correctly documented by Oracle.
    So your database is OK: using dynamic views is the right way to check your instance and session parameters.

  • Column Length Semantics  and Table Columns - NLS_LENGTH_SEMANTICS

    Is NLS_LENGTH_SEMANTICS defined in oracle 10g?
    if not what is its equivalent.
    Please let me know about this.

    $ sqlplus / as sysdba
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon May 22 23:30:14 2006
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SYS@db102 SQL> select * from nls_database_parameters
      2  where parameter = 'NLS_LENGTH_SEMANTICS';
    PARAMETER                      VALUE
    NLS_LENGTH_SEMANTICS           BYTE
    SYS@db102 SQL>                                                                  

  • NLS_LENGTH_SEMANTICS=CHAR not effective?

    Hi,
    I have two Oracle 10.2.0.3 databases - DB1 & DB2.
    In both, following init.ora parameter is set :- NLS_LENGTH_SEMANTICS=CHAR
    In DB1, for one query i received ORA-12899: value too large for column <tbsp1>.<tb1>.<col1> (actual: 17, maximum: 16)
    In DB2, for the same query, didn't face any problems.
    When i compared, the same table tb1 in both databases -
    For DB2:
    SQL> desc tb1;
    Name Null? Type
    col1 VARCHAR2(30 CHAR)
    col2 VARCHAR2(50 CHAR)
    =======================================
    For DB1:
    SQL> desc tb1;
    Name Null? Type
    col1 VARCHAR2(30)
    col2 VARCHAR2(50)
    If observed, column type for DB1 is VARCHAR2(30) and for DB2 its VARCHAR2(30 'CHAR').
    To give you further details - Both the databases,DB1 & DB2 are on the same OS platform, have same init.ora parameters, every configuration is same, except both are installed on different servers.
    Please help me for this problem which i am facing in DB1.
    Edited by: user10552003 on Jan 27, 2011 4:42 PM

    If you want to change the character length semantics for all the columns, you just need a bit of dynamic SQL. Something like
    DECLARE
      l_sql VARCHAR2(1000);
    BEGIN
      FOR cols IN (SELECT * FROM user_tab_cols WHERE data_type = 'VARCHAR2' and char_used = 'B')
      LOOP
        l_sql :=
          'ALTER TABLE ' || cols.table_name ||
          '  MODIFY( ' || cols.column_name || ' VARCHAR2(' || cols.data_length || ' CHAR) )';
        dbms_output.put_line( l_sql );
        execute immediate l_sql;
      END LOOP;
    END;If you want to change the character semantics for tables in other schemas, you'll need to run this in each schema or change the code to use DBA_TAB_COLS. I'm also not doing any exception handling here to account for situations like object tables where this code won't work correctly.
    Justin

  • NLS_LENGTH_SEMANTICS issue on db10g v.2

    Hi,
    Having connected as sys , i issued the command:
    alter system set NLS_LENGTH_SEMANTICS='CHAR' SCOPE=BOTH on db10g v.2 (db characterset :AL32UTF16).
    When i issue the command:
    select * from nls_session_parameter and select * from nls_instance_parameter i get NLS_LENGTH_SEMANTICS -> CHAR
    but when i issue the command:
    select * from nls_database_parameter , i get NLS_LENGTH_SEMANTICS -> BYTE...
    Having connected as SCOTT
    select * from nls_session_parameter .. i get NLS_LENGTH_SEMANTICS -> CHAR.
    The problem is apparent in the following scenario:
    connected as scott
    create table test(g varchar2(10));
    desc test;
    Name                                            Null?       Type
    G                                                                 VARCHAR2(10 CHAR)insert into test values('γδξειδφ'); <--------some greek characters
    ORA-12899 :value too large for column "SCOTT" ."G" (actual :14 , maximum :10)
    What may be the cause...????
    Why nls_database_parameters show that NLS_LENGTH_SEMANTICS=BYTE?
    Thanks.....
    Sim

    An ALTER SYSTEM does not change the DATABASE.
    What you may want to do is more along these lines:
    ALTER DATABASE CHARACTER SET WE8MSWIN1252;
    -- if the above fails:
    ALTER DATABASE CHARACTER SET INTERNAL_USE WE8MSWIN1252;
    SHUTDOWN IMMEDIATE;
    STARTUP;But before you do so read the docs very carefully and fully understand the implications.
    And, of course WE8 is not the correct solution for what you are doing so choose an appropriate character set.

  • NLS_LENGTH_SEMANTICS, how does it work?

    The tilde character produced below is going to take up at least a couple of bytes and because my NLS_LENGTH_SEMANTICS is set to byte "x" is i assume only capable of storing 1 byte so shouldn't the code excerpt throw up an error?
    When i run this code in TOAD (Tool for Oracle Application Developers) i don't get an error either BUT the character produced is "ã" as expected but in the SQLPLUS console i am getting "Ò", how can that be?
    Cheers
    Gus
    DevSQL>set serveroutput on
    DevSQL>select * from nls_session_parameters;
    PARAMETER                      VALUE
    NLS_LANGUAGE                   ENGLISH
    NLS_TERRITORY                  UNITED KINGDOM
    NLS_CURRENCY                   ú
    NLS_ISO_CURRENCY               UNITED KINGDOM
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              ENGLISH
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH24.MI.SSXFF
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH24.MI.SSXFF
    PARAMETER                      VALUE
    NLS_TIME_TZ_FORMAT             HH24.MI.SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH24.MI.SSXFF TZR
    NLS_DUAL_CURRENCY              Ç
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    17 rows selected.
    DevSQL>declare
      2     x VARCHAR2(1) := compose(unistr('a\0303'));
      3  begin
      4     dbms_output.put_line(x);
      5  end;
      6  /
    Ò
    PL/SQL procedure successfully completed.

    Sorry Justin the following output would have been more informative for my original posting...
    DevSQL>select * from nls_database_parameters;
    PARAMETER                      VALUE
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CHARACTERSET               WE8MSWIN1252
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    PARAMETER                      VALUE
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    NLS_NCHAR_CHARACTERSET         AL16UTF16
    NLS_RDBMS_VERSION              9.2.0.1.0
    20 rows selected.
    DevSQL>declare
      2     chars VARCHAR2(1) := length(compose(unistr('a\0303')));
      3     uni_chars number(1) := lengthc(compose(unistr('a\0303')));
      4     uni_chars_un number(1) := lengthc(unistr('a\0303'));
      5     bytes number(1) := lengthb(compose(unistr('a\0303')));
      6  begin
      7     dbms_output.put_line('Character length...' || chars);
      8     dbms_output.put_line('Unicode character length is...' || uni_chars);
      9     dbms_output.put_line('Uncomposed unicode character length is...' || uni_chars_un);
    10     dbms_output.put_line('Byte length is...' || bytes);
    11  end;
    12  /
    Character length...1
    Unicode character length is...1
    Uncomposed unicode character length is...1
    Byte length is...2
    PL/SQL procedure successfully completed.

Maybe you are looking for