Setting up NLS_LENGTH_SEMANTICS
parameter
Baldish Virk
IPS, Germany
2
Problem
Characters get truncated while reading data or profiling or in data viewer in Developer when
NLS_LENGTH_SEMANTICS is BYTE in source database and the data contains multi-byte
characters.
Solution
Add ALTER SESSION SET NLS_LENGTH_SEMANTICS=CHAR under Environment SQL
for all ODBC connections.
Document1
Page 2 of 5
3
Overview
NLS_LENGTH_SEMANTICS is an Oracle database parameter, which can have value has a
BYTE or a CHAR value depending on the database character set support. By default, it's value is
set to BYTE.
Starting with Oracle 9i, a new parameter called NLS_LENGTH_SEMANTICS was introduced
that can either be set to "CHAR" or "BYTE".
If the NLS_LENGTH_SEMANTICS is set to BYTE, then a column declared as
VARCHAR(10) would be interpreted as 10 bytes, if it is set to CHAR then the column would
be interpreted as 10 characters.
Which database views are useful to query this parameter value?
This parameter value can be queried under the following database views:
•
nls_database_parameters at the Database Level.
•
nls_instance_parameters at an Instance Level.
•
nls_session_parameters at Session Level.
Session Level:
select VALUE from NLS_SESSION_PARAMETERS where
PARAMETER='NLS_LENGTH_SEMANTICS'
Database Level:
select * from v$nls_parameters where parameter =upper('nls_length_semantics')
Document1
Page 3 of 5
4
Which location is recommended to set this parameter?
This parameter should be set at Database and Instance level only.
Why it is used in Developer?
This is used for non-English characters. This parameter is set to CHAR so that the Oracle
underlying tables are created using CHAR semantics for a CHAR, or a VARCHAR2 column.
.
What is the other environment variables that need to be modified?
The following environment variables have to be modified respectively:
NLS_LANG (export NLS_LANG=AMERICAN_AMERICA.AL32UTF8)
Document1
Page 4 of 5
5
What is NLS_LENGTH_SEMATICS
NLS_LENGTH_SEMANTICS
Property
Description
Parameter type
String
Syntax
NLS_LENGTH_SEMANTICS = string
Example: NLS_LENGTH_SEMANTICS = 'CHAR'
Default value
BYTE
Modifiable
ALTER SESSION
Range of values
BYTE | CHAR
The session-level value of NLS_LENGTH_SEMANTICS specifies the default length
semantics to use for VARCHAR2 and CHAR table columns, user-defined object attributes, and
PL/SQL variables in database objects created in the session. This default may be overridden by
the explicit length semantics qualifiers BYTE and CHAR in column, attribute, and variable
definitions.
The instance-level value of NLS_LENGTH_SEMANTICS provides a default for the sessionlevel value if NLS_LENGTH_SEMANTICS it is not set explicitly by the database client
through the NLS_LENGTH_SEMANTICS client environment variable (does not apply to
JDBC Thin clients), or the ALTER SESSION SET NLS_LENGTH_SEMANTICS
statement.
NCHAR, NVARCHAR2, CLOB, and NCLOB columns are always character-based.
Sessions logged in as SYS do not use the NLS_LENGTH_SEMANTICS parameter. They use
BYTE length semantics for all created objects unless overridden by the explicit BYTE and
CHAR qualifiers in object definitions (SQL DDL statements).
Caution:
Oracle strongly recommends that you do NOT set the NLS_LENGTH_SEMANTICS
parameter to CHAR in the instance or server parameter file. This may cause many existing
installation scripts to unexpectedly create columns with character length semantics, resulting in
runtime errors, including buffer overflows.
Document1
Page 5 of 5
© Copyright 2026 Paperzz