Alter Session Oracle PL/SQL
Change Schema
ALTER SESSION can be used with a database has multiple schema owners. Example: a single database instance contains both development and test environments.
You need to alter your session in order to be able to access the tables that are not in your default schema. For this example you will need to access the test table PS_VOUCHER which happens to be in the SYSADM and the SYSDEV schema. You are logged into the default SYSDEV schema but you need to use the other table. You can access this by appending SYSADM to each of the tables but that seems like a lot of work. You can do the following to change the schema for all the tables.
1 | ALTER SESSION SET CURRENT_SCHEMA = SYSADM |
Change NLS_DATE_FORMAT
Use this to set the date format in an SQR (or SQL Plus) to a format that will return all dates form the database to the SQR in the standard format instead of using the TO_DATE function in every SQL statement all over the SQR.
1 | ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD' |
Using ALTER SESSION can be helpful and make your code easier to read and maintain.