ALTER SESSION
The ALTER SESSION statement changes session parameters dynamically. This overrides the setting of the equivalent connection attribute for the current session, as applicable.
                  
Required Privilege
None
Usage with TimesTen Scaleout
This statement is supported with TimesTen Scaleout. However, these parameters are not supported:
- 
                        DDL_REPLICATION_ACTION
- 
                        DDL_REPLICATION_LEVEL
- 
                        REPLICATION_TRACK
SQL Syntax
ALTER SESSION SET
  {COMMIT_BUFFER_SIZE_MAX = n |
   DDL_REPLICATION_ACTION={'INCLUDE'|'EXCLUDE'} | 
   DDL_REPLICATION_LEVEL={1|2|3} |
   ISOLATION_LEVEL = {SERIALIZABLE | READ COMMITTED} |
   NLS_SORT = {BINARY| SortName} |
   NLS_LENGTH_SEMANTICS = {BYTE|CHAR} |
   NLS_NCHAR_CONV_EXCP = {TRUE|FALSE} |
   PLSQL_TIMEOUT = n |
   PLSQL_OPTIMIZE_LEVEL = {0|1|2|3}|
   PLSQL_CONN_MEM_LIMIT = n |
   PLSQL_CCFLAGS = 'name1:value1, name2:value2,..., nameN:valueN' |
   PLSQL_SESSION_CACHED_CURSORS = n |
   REPLICATION_TRACK = TrackNumber |
   } Parameters
| Parameter | Description | 
|---|---|
| 
 | Changes the maximum size of the commit buffer when a connection is in progress. n is expressed as an integer and represents the maximum size of the commit buffer (in MB). Change takes effect starting with the next transaction. Call the  For more information on the commit buffer and transaction reclaim operations, see Transaction Reclaim Operations in the Oracle TimesTen In-Memory Database Operations Guide and CommitBufferSizeMax in the Oracle TimesTen In-Memory Database Reference. Note: The equivalent connection attribute is  | 
| 
 | To include a table or sequence in the active standby pair when either is created, set  If set to  
 This attribute is valid only if  See Making DDL Changes in an Active Standby Pair in the Oracle TimesTen In-Memory Database Replication Guide for more information. Note: The equivalent connection attribute is  | 
| 
 | Indicates whether DDL is replicated across all databases in an active standby pair. The value can be one of the following: 
 See Making DDL Changes in an Active Standby Pair in the Oracle TimesTen In-Memory Database Replication Guide for more information. Note: The equivalent connection attribute is  | 
| 
 | Sets isolation level. Change takes effect starting with the next transaction. For a descriptions of the isolation levels, see Transaction Isolation Levels in the Oracle TimesTen In-Memory Database Operations Guide. Note: The equivalent connection attribute is  | 
| 
 | Indicates which collation sequence to use for linguistic comparisons. Append  If you do not specify  For a complete list of supported values for  For more information on case-insensitive or accent-insensitive sorting, see Case-Insensitive and Accent-Insensitive Linguistic Sorts in Oracle TimesTen In-Memory Database Operations Guide. | 
| 
 | Sets the default length semantics configuration.  For more information on length semantics, see Character Set Length Semantics Affect Data Storage in Oracle TimesTen In-Memory Database Operations Guide. | 
| 
 | Determines whether an error should be reported when there is data loss during an implicit or explicit character type conversion between  | 
| 
 | Controls how long PL/SQL procedures run before being automatically terminated.   When you modify this value, the new value impacts PL/SQL program units that are currently running as well as any other program units subsequently executed in the same connection. See Choose SQL and PL/SQL Timeout Values in the Oracle TimesTen In-Memory Database Operations Guide for information on setting timeout values. | 
| 
 | Specifies the optimization level used to compile PL/SQL library units. The higher the setting, the more effort the compiler makes to optimize PL/SQL library units. Possible values are 0, 1, 2 or 3. The default is 2. For more information, see PLSQL_OPTIMIZE_LEVEL in Oracle TimesTen In-Memory Database Reference. | 
| 
 | Specifies the maximum amount of process heap memory that PL/SQL can use for this connection, where  For more information, see PLSQL_CONN_MEM_LIMIT in Oracle TimesTen In-Memory Database Reference. | 
| 
 | Specifies inquiry directives to control conditional compilation of PL/SQL units, which enables you to customize the functionality of a PL/SQL program depending on conditions that are checked. For example, to activate debugging features: PLSQL_CCFLAGS = 'DEBUG:TRUE' | 
| 
 | Specifies the maximum number of session cursors to cache. The default is 50. The range of values is 1 to 65535. The  | 
| 
 | When managing track-based parallel replication, you can assign a connection to a replication track. All transactions issued by the connection are assigned to this track, unless the track is altered. If the number specified is for a non-existent replication track  You cannot change tracks in the middle of a transaction unless all preceding operations have been read operations. For more information, see Specifying Replication Tracks Within an Automatic Parallel Replication Environment in Oracle TimesTen In-Memory Database Replication Guide. The equivalent connection attribute is  | 
Description
- 
                        The ALTER SESSIONstatement affects commands that are subsequently executed by the session.ALTERSESSIONdoes not do an implicit commit.
- 
                        In cases of client failover, if an ALTERSESSIONstatement is issued in the failed connection, the setting is not seen or carried over to the new connection. You must re-issue theALTERSESSIONstatement and re-specify the value for that parameter. For more information on client failover, in TimesTen Classic, see Using Automatic Client Failover in the Oracle TimesTen In-Memory Database Operations Guide and, in TimesTen Scaleout, see Client Connection Failover in the Oracle TimesTen In-Memory Database Scaleout User's Guide.
- 
                        Operations involving character comparisons support linguistic sensitive collating sequences. Case-insensitive sorts may affect DISTINCTvalue interpretation.
- 
                        Implicit and explicit conversions between CHARandNCHARare supported.
- 
                        You can use the SQL string functions with the supported character sets. For example, UPPERandLOWERfunctions support non-ASCIICHARandVARCHAR2characters as well asNCHARandNVARCHAR2characters.
- 
                        Choice of character set could have an impact on memory consumption for CHARandVARCHAR2column data.
- 
                        The character sets of all databases involved in a replication scheme must match. 
- 
                        To add an existing table to an active standby pair, set DDL_REPLICATION_LEVELto 2 or greater andDDL_REPLICATION_ACTIONtoINCLUDE. Alternatively, you can use theALTER ACTIVE STANDBY PAIR ... INCLUDE TABLEstatement ifDDL_REPLICATION_ACTIONis set toEXCLUDE. In this case, the table must be empty and present on all databases before executing theALTER ACTIVE STANDBY PAIR ... INCLUDE TABLEstatement as the table contents will be truncated when this statement is executed.
- 
                        To add an existing sequence or view to an active standby pair, set DDL_REPLICATION_LEVELto 3. To include the sequence in the replication scheme,DDL_REPLICATION_ACTIONmust be set toINCLUDE. This does not apply to materialized views.
- 
                        Objects are replicated only when the receiving database is of a TimesTen release that supports that level of replication, and is configured for an active standby pair replication scheme. For example, replication of sequences (requiring DDL_REPLICATION_LEVEL=3) to a database release prior to 11.2.2.7.0 is not supported. The receiving database must be of at least release 11.2.1.8.0 for replication of objects supported byDDL_REPLICATION_LEVEL=2.
Examples
Use the ALTER SESSION statement to change COMMIT_BUFFER_SIZE_MAX to 500 MB. First, call ttConfiguration to display the current connection setting. Use the ALTER SESSION statement to change the COMMIT_BUFFER_SIZE_MAX setting to 500. Call ttConfiguration to display the new setting.
                  
Command>  CALL ttConfiguration ('CommitBufferSizeMax');
< CommitBufferSizeMax, 0 >
1 row found.
Command> ALTER SESSION SET COMMIT_BUFFER_SIZE_MAX = 500;
 
Session altered.
 
Command> CALL ttConfiguration ('CommitBufferSizeMax');
< CommitBufferSizeMax, 500 >
1 row found.
Use the ALTER SESSION statement to change PLSQL_TIMEOUT to 60 seconds. Use a second ALTER SESSION statement to change PLSQL_OPTIMIZE_LEVEL to 3. Then call ttConfiguration to display the new values.
                  
Command> ALTER SESSION SET PLSQL_TIMEOUT = 60; Session altered. Command> ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL = 3; Session altered. Command> CALL TTCONFIGURATION (); < CkptFrequency, 600 > < CkptLogVolume, 0 > < CkptRate, 0 > ... < PLSQL_OPTIMIZE_LEVEL, 3 > < PLSQL_TIMEOUT, 60 > ... 47 rows found.
In this example, set PLSQL_TIMEOUT to 20 seconds. Attempt to execute a program that loops indefinitely. In 20 seconds, execution is terminated and an error is returned.
                  
Command> ALTER SESSION SET PLSQL_TIMEOUT = 20;
Command> DECLARE v_timeout NUMBER;
         BEGIN
           LOOP
             v_timeout :=0;
             EXIT WHEN v_timeout < 0;
           END LOOP;
         END;
         /
 8509: PL/SQL execution terminated; PLSQL_TIMEOUT exceeded
The following example uses the ALTER SESSION statement to change the NLS_SORT setting from BINARY to BINARY_CI to BINARY_AI. The database and connection character sets are WE8ISO8859P1.
                  
Command> connect "dsn=cs;ConnectionCharacterSet=WE8ISO8859P1";
Connection successful: DSN=cs;UID=user;DataStore=/datastore/user/cs;
DatabaseCharacterSet=WE8ISO8859P1;
ConnectionCharacterSet=WE8ISO8859P1;PermSize=32;
(Default setting AutoCommit=1)
Command> -- Create the Table
Command> CREATE TABLE collatingdemo (letter VARCHAR2 (10));
Command> -- Insert values
Command> INSERT INTO collatingdemo VALUES ('a');
1 row inserted.
Command> INSERT INTO collatingdemo VALUES ('A');
1 row inserted.
Command> INSERT INTO collatingdemo VALUES ('Y');
1 row inserted.
Command> INSERT INTO collatingdemo VALUES ('ä');
1 row inserted.
Command> -- SELECT
Command> SELECT * FROM collatingdemo;
< a >
< A >
< Y >
< ä >
4 rows found.
Command> --SELECT with ORDER BY
Command> SELECT * FROM collatingdemo ORDER BY letter;
< A >
< Y >
< a >
< ä >
4 rows found.
Command>-- set NLS_SORT to BINARY_CI and SELECT
Command> ALTER SESSION SET NLS_SORT = BINARY_CI;
Command> SELECT * FROM collatingdemo ORDER BY letter;
< a >
< A >
< Y >
< Ä >
< ä >
4 rows found.
Command> -- Set NLS_SORT to BINARY_AI and SELECT
Command> ALTER SESSION SET NLS_SORT = BINARY_AI;
Command> SELECT * FROM collatingdemo ORDER BY letter;
< ä >
< a >
< A >
< Y >
4 rows found.
The following example enables automatic parallel replication with disabled commit dependencies. It uses the ALTER SESSION statement to change the replication track number to 5 for the current connection. To enable automatic parallel replication with disabled commit dependencies for replication schemes, set ReplicationApplyOrdering to 2. Then, always set REPLICATION_TRACK to a number less than or equal to ReplicationParallelism. For example, the ReplicationParallelism connection attribute could be set to 6, which is higher than the value of 5 set for REPLICATION_TRACK. 
                  
Command> ALTER SESSION SET REPLICATION_TRACK = 5; Session altered.
The following example enables replication of adding and dropping columns, tables, synonyms and indexes by setting the following on the active database in an alter standby replication pair: DDL_REPLICATON_LEVEL set to 2 and DDLReplicationAction set to 'INCLUDE'.
                  
Command > ALTER SESSION SET DDL_REPLICATION_LEVEL=2; Session altered. Command > ALTER SESSION SET DDL_REPLICATION_ACTION='INCLUDE'; Session altered.
Note:
The equivalent connection attributes for DDL_REPLICATION_LEVEL and DDL_REPLICATION_ACTION are DDLReplicationLevel and DDLReplicationAction, respectively.