Precision of NVARCHAR2 column is 1.5 times lower than displayed by desc command

The problem is in the NLS_NCHAR_CHARACTERSET = UTF8. I simulated the same table in a different database with NLS_NCHAR_CHARACTERSET = AL16UTF16. The describe statement shows the correct length as defined while creating table.

UTF8 can be 1, 2, 3 or 6 bytes / character, any AL32UTF8 character that is 4 bytes will be stored as 2 time 3 bytes in UTF8. If you want to store 1 byte character in UTF8 it takes 1.5 bytes (1*1.5=1.5).

For further details, see:

AL32UTF8 / UTF8 (Unicode) Database Character Set Implications [ID 788156.1]


I'm quite sure that this is a problem of SQL Developer... Retry to desc table after issuing:

alter session set NLS_LENGTH_SEMANTICS='CHAR';

Is correct now? If not try to desc the table using sqlplus on the database server bypassing the Oracle Listener:

>export NLS_LANG=AMERICAN_SWITZERLAND.AL32UTF8 
>export ORACLE_SID=<YOURINSTANCESID>
>sqlplus / as sysdba
>sqlplus>desc owner.table

If the result is not correct, execute:

SQLPLUS>alter session set NLS_LENGTH_SEMANTICS='CHAR'; SQLPLUS>desc owner.table

If you can'tdo it on the server try the same with you sqldeveloper (but you will not bypass the listener):

>set NLS_LANG=AMERICAN_SWITZERLAND.AL32UTF8 
>C:\oracle\client\product\12.1.0\client\sqldeveloper\sqldeveloper\bin\sqldevelope‌​rW.exe

Change the sqldevelope‌​rW.exe path. Let me know When you declare a nvarchar2 field, the size is expressed ALWAYS in char. With desc command you are viewing the size in bytes. Sqldeveloper in some way is not able to display the vlaue in char. Also you can try to update your sqldevleoper version.

Giova

Note: I do not find Offical Oracle documentation about but this wiki explains better this behavior of sql developer:

Setting NLS LENGTH SEMANTICS

In the past I found the same problem with plsqldeveloper and other clients. Maybe the most updated versions works correctly.