NLS Parameters Display (nls_parms.sql)
What This Script Does
Section titled “What This Script Does”Displays National Language Support (NLS) parameters at three different levels: session, instance, and database. This comprehensive view helps understand how NLS settings are configured and inherited across different scopes.
The Script
Section titled “The Script”rem nls_parms.sqlremttitle 'NLS Parameters - All Levels'remcol parameter format a30col value format a30remSELECT '-- SESSION --' PARAMETER, '' VALUE FROM DUALUNIONSELECT Parameter , Value FROM NLS_SESSION_PARAMETERS ORDER BY 1/remSELECT '-- INSTANCE --' PARAMETER, '' VALUE FROM DUALUNIONSELECT Parameter , Value FROM NLS_INSTANCE_PARAMETERS ORDER BY 1/remSELECT '-- DATABASE --' PARAMETER, '' VALUE FROM DUALUNIONSELECT Parameter , Value FROM NLS_DATABASE_PARAMETERS ORDER BY 1/
-- Display all NLS parameters at all levels@nls_parms.sql
Parameters
Section titled “Parameters”The script requires no input parameters and displays all NLS settings.
Required Privileges
Section titled “Required Privileges”-- Usually available to all usersSELECT on NLS_SESSION_PARAMETERSSELECT on NLS_INSTANCE_PARAMETERSSELECT on NLS_DATABASE_PARAMETERS
Sample Output
Section titled “Sample Output” NLS Parameters - All Levels
PARAMETER VALUE------------------------------ -------------------------------- SESSION --NLS_CALENDAR GREGORIANNLS_COMP BINARYNLS_CURRENCY $NLS_DATE_FORMAT DD-MON-RRNLS_DATE_LANGUAGE AMERICANNLS_DUAL_CURRENCY $NLS_ISO_CURRENCY AMERICANLS_LANGUAGE AMERICANNLS_LENGTH_SEMANTICS BYTENLS_NCHAR_CONV_EXCP FALSENLS_NUMERIC_CHARACTERS .,NLS_SORT BINARYNLS_TERRITORY AMERICANLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AMNLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZRNLS_TIME_FORMAT HH.MI.SSXFF AMNLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
-- INSTANCE --[Instance-level parameters...]
-- DATABASE --[Database-level parameters...]
Key NLS Parameters
Section titled “Key NLS Parameters”Date and Time Formatting
NLS_DATE_FORMAT
: Default date display formatNLS_TIMESTAMP_FORMAT
: Timestamp display formatNLS_TIME_FORMAT
: Time display formatNLS_CALENDAR
: Calendar system (Gregorian, Japanese, etc.)
Language and Territory
NLS_LANGUAGE
: Default language for messages and sortingNLS_TERRITORY
: Territory for number and date conventionsNLS_DATE_LANGUAGE
: Language for day/month names
Character and Numeric
NLS_LENGTH_SEMANTICS
: BYTE or CHAR length semanticsNLS_NUMERIC_CHARACTERS
: Decimal and group separatorsNLS_CURRENCY
: Currency symbolNLS_ISO_CURRENCY
: ISO currency code
Sorting and Comparison
NLS_SORT
: Sorting method for character dataNLS_COMP
: String comparison method
Parameter Hierarchy
Section titled “Parameter Hierarchy”Precedence Order (highest to lowest)
- Session Level: ALTER SESSION SET commands
- Instance Level: Initialization parameters (spfile/pfile)
- Database Level: Database creation defaults
Understanding Inheritance
- Session parameters override instance parameters
- Instance parameters override database parameters
- Explicit session settings take highest precedence
Common Use Cases
Section titled “Common Use Cases”Globalization Troubleshooting
-- Check NLS settings when data appears incorrectly@nls_parms.sql-- Compare session vs. instance settings
Application Development
-- Verify NLS settings for international applications@nls_parms.sql-- Ensure consistent formatting across environments
Date Format Issues
-- Investigate date display problems@nls_parms.sql-- Check NLS_DATE_FORMAT and NLS_DATE_LANGUAGE
Multi-Language Support
-- Verify language and territory settings@nls_parms.sql-- Ensure proper character set configuration
Migration and Deployment
-- Compare NLS settings between environments@nls_parms.sql-- Ensure consistent configuration across systems
Level-Specific Analysis
Section titled “Level-Specific Analysis”Session Level
- Current session’s effective settings
- May be modified by ALTER SESSION commands
- Reflects user-specific or application-specific changes
Instance Level
- Settings from initialization parameters
- Apply to all new sessions by default
- Set via spfile/pfile or ALTER SYSTEM
Database Level
- Default settings established at database creation
- Baseline configuration for the database
- Cannot be changed after database creation
Common Issues and Solutions
Section titled “Common Issues and Solutions”Date Format Inconsistencies
-- Check if session format differs from instance-- Look for NLS_DATE_FORMAT differences between levels
Character Length Issues
-- Verify NLS_LENGTH_SEMANTICS setting-- BYTE vs. CHAR can affect VARCHAR2 column behavior
Sorting Problems
-- Check NLS_SORT parameter-- Different sorting methods affect ORDER BY results
Currency Display Issues
-- Verify NLS_CURRENCY and NLS_ISO_CURRENCY-- Ensure proper currency symbol display
Performance Impact
Section titled “Performance Impact”- Minimal: Simple queries on system views
- Read-Only: No modifications to settings
- Fast Execution: Instantaneous results
Related Scripts
Section titled “Related Scripts”- nls_session_parameters - Session-only NLS parameters
- Database configuration and setup scripts
- Application deployment verification scripts
Best Practices
Section titled “Best Practices”Environment Consistency
- Maintain consistent NLS settings across environments
- Document any intentional differences
- Test applications with various NLS configurations
Application Development
- Use explicit format masks in critical applications
- Don’t rely solely on default NLS settings
- Test with different locale configurations