Skip to Main Content
  • Questions
  • Letter ù is OK for the table's name but not for a column's name

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, David.

Asked: August 06, 2018 - 2:50 pm UTC

Last updated: December 13, 2018 - 4:35 am UTC

Version: 12.1

Viewed 1000+ times

You Asked

Hello The Oracle Masters,

I have the following problem : impossible to use the lettre ù for a column's name but it is OK for a table's name.

Very important : I use Windows 7, in French, and the Oracle 12.1 virtual box with Linux. My principal client is SQL*Plus : Release 12.2.0.1.0.

Ah, one thing, SQL*Plus allow me to create and use a table called ù but not SQL Developer...

Here is the configuration of my database : language AMERICAN and unicode AL16UTF16.
SQL> select parameter, value from v$nls_parameters order by parameter;
     PARAMETER                             VALUE
     ---------------------------------------------------------------- 
     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
     
     19 rows selected.


Here is the problem. I create a table with a column named ù BUT after that, it is impossible to use this name, even with "".
SQL> CREATE TABLE testaccent (ù VARCHAR2(10));
     Table created.
     
     SQL> desc testaccent
     Name            Null?   Type
     ---------------- ---------------------
     ??                        VARCHAR2(10)

     SELECT COLUMN_NAME from user_tab_cols where TABLE_NAME = 'TESTACCENT'; 
     COLUMN_NAME
     ------------
     ??

Same error with SQL*Plus and SQL Developer.
     SQL> select ù from test02;
     select ù from test02
            *
     ERROR at line 1:
     ORA-00904: "??": invalid identifier
     
     SQL> select "ù" from test02;
     select "ù" from test02
            *
     ERROR at line 1:
     ORA-00904: "??": invalid identifier
  
     SQL> SELECT ?? FROM testaccent;
     SELECT ?? FROM testaccent
            *
     ERROR at line 1:
     ORA-00911: invalid character
     
     SQL> SELECT "??" FROM testaccent;
     ERROR at line 1:
     ORA-00904: "??": invalid identifier


Well, I thought the character ù wasn't recognize until I create a table called ù.
SQL> CREATE TABLE ù (ID NUMBER);
     Table created.


The table's name is also ??, like before for the column's name.
SQL> select table_name from user_tables order by 1;
     TABLE_NAME
     --------------
     COUNTRIES
     DEPARTMENTS
     EMPLOYEES
     JOBS
     JOB_HISTORY
     LOCATIONS
     REGIONS
     TESTACCENT
     ??


And, surprisingly, I can use the letter ù to identifie this table but only with SQL*Plus.
SQL*Plus
SQL> insert into ù values (1);
     1 row created.

SQL Developer
SQL> insert into ù values (1);
Error starting at line : 1 in command -
insert into ù values (1)
Error at Command Line : 1 Column : 13
Error report -
SQL Error: ORA-00942: table or view does not exist
00942. 00000 -  "table or view does not exist"
*Cause:    
*Action
  
     SQL> commit;
     Commit complete.
     
SQL*Plus : OK
     SQL> select * from ù;
         ID
     ----------
          1
SQL Developer : KO.
     SQL> select * from ù;
ORA-00942: table or view does not exist
00942. 00000 -  "table or view does not exist"
*Cause:    
*Action:
Error at Line: 1 Column: 15




Can you explain us why there is this difference between a table's name and a column's name?
Thank you for your answer and have a very good day,

David D.


[UPDATE 17/08/2018]
Hi Sergiusz,
I have done all the required test in SQL Developer and the results are OK.

BUT, I am very confusing, I had two days ago a problem with my database and I had to drop it and recreate it. And now I have no problem with SQL*Plus. So, I think it was a configuration problem with my last database.

Test with SQL Developer.
create table ù (ù varchar2(10));
Table Ù created.

select ù from ù;
no rows selected

drop table ù purge.
Table dropped.


Test with SQL*Plus.
create table ù (ù varchar2(10));
Table Ù created.

select ù from ù;
no rows selected

drop table ù purge.
Table dropped.

Best regards,

David

and we said...

Generally, if you test with SQL Developer and an AL32UTF8 Unicode database, then everything will work correctly, because SQL Developer works internally in Unicode and no special configuration is usually needed for most languages (some font configuration may be needed for more "exotic" languages).

SQL*Plus, on the other hand, is problematic. On Windows, it is written to Win32 ANSI API. When your run it in a Command Prompt window, this window works in the ANSI or OEM code page that you can check with the CHCP command. On French Windows, it will be the OEM code page 850 by default (Oracle name: WE8PC850). You have to let SQL*Plus know this code page by setting the NLS_LANG environment variable appropriately. By default, SQL*Plus sees the NLS_LANG setting from Registry, which is usually .WE8MSWIN1252 (ANSI code page 1252). WE8MSWIN1252 is not the same as WE8PC850, and this is why you see the problems -- 'ù' is 0xF9 in WE8MSWIN1252 but 0x97 in WE8PC850. Do not get deceived by the fact that you see the letter correctly on the screen. The database may see it as a different character. For example, if the code 0x97 received for 'ù' from the Command Prompt by SQL*Plus is interpreted in WE8MSWIN1252 (as dictated by the Registry setting), the database will think it is the em-dash ('—') character and not accept it as an unquoted identifier.

You have to make sure the code page of Command Prompt agrees with the NLS_LANG value seen by SQL*Plus. You can do this either by setting NLS_LANG before running SQL*Plus:

C:\>chcp
Active code page: 850
C:\>set NLS_LANG=FRENCH_FRANCE.WE8PC850
C:\>sqlplus /nolog

or by setting the Command Prompt code page as set in Registry:

C:\>sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Sat Sep 1 00:19:36 2018

Copyright (c) 1982, 2016, Oracle. All rights reserved.

SQL> @%NLS_LANG%
SP2-0310: unable to open file "AMERICAN_AMERICA.WE8MSWIN1252"
SQL> exit

C:\> chcp 1252
Active code page: 1252

C:\>sqlplus /nolog

Do not modify Registry to .WE8PC850 or set the environment variable in system properties permanently, because these setting are used by GUI applications as well and Windows GUI runs in code page 1252, not 850. Preferably, start SQL*Plus via a batch file that sets the NLS_LANG environment variable temporarily. Or, just use SQL Developer.


Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

David, September 01, 2018 - 7:36 am UTC


Hello Sergiusz,
Thank you very much for your answer.

I am a little bit disapointing to read that SQL Developer is better than SQL*Plus on that point because I valid my code with SQL*Plus and I always trusted it.
But, I am here to learn :-)

Best regards,

David


Sergiusz Wolicki
September 09, 2018 - 10:39 pm UTC

This is an unfortunate side effect of Command Prompt being a descendant of MS-DOS and SQL*Plus being a Command Prompt application. SQL Developer (or any other GUI application written to UTF-16 APIs) is simply more modern in respect to internationalization.

sqlcl and sql*plus

David DUBOIS, December 12, 2018 - 1:34 pm UTC


Hello Masters,

I am testing sqlcl to see if it is a good soft and, Yes, definitively Yes for my problem with ù :-)

With SQL*Plus : Oh my god...
SQL> select length('ù'), lengthb('ù') from dual;
LENGTH('??') LENGTHB('??')
------------ -------------
2 6


With sqlcl : yes, better!
SQL> select length('ù'), lengthb('ù') from dual;
LENGTH('Ù') LENGTHB('Ù')
----------- ------------
1 2


If I have problem with special characters, now I know what to use : sqlcl.

Thanks to Oracle for this soft.

David DUBOIS



Connor McDonald
December 13, 2018 - 4:35 am UTC

SQLPlus can do it...but if you're running it on (say) a Windows machine, you need to make sure *terminal* can also handle it.


C:\>set ORACLE_PATH=c:\oracle\sql

C:\>set SQLPATH=c:\oracle\sql

C:\>set ORACLE_SID=db122

C:\>set PATH=C:\oracle\product\12.2.0.1\bin;%PATH%

C:\>chcp 65001
Active code page: 65001

C:\>set NLS_LANG=AMERICAN_AMERICA.UTF8

C:\>sqlplus scott/tiger

SQL*Plus: Release 18.0.0.0.0 - Production on Thu Dec 13 12:31:56 2018
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Last Successful login time: Thu Nov 08 2018 12:03:27 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production


SQL> @c:\tmp\x1.sql
SQL> select length('ù'), lengthb('ù') from dual;

LENGTH('Ù') LENGTHB('Ù')
----------- ------------
          1            2

SQL>


More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database