SQLcl : commande SHOW et informations de la base courante - SQLcl: SHOW command and information from the current database
Introduction
SQLcl (SQL Command Line) est un utilitaire Java intégré dans Oracle depuis la 12.2, alors qu'auparavant il fallait l'installer à part. Il est basé sur l'outil gérant les scripts SQL de SQL Developer et intègre de nouvelles commandes par rapport à SQL*Plus.
Dans cet article nous verrons les options de la commande SHOW qui n'existent pas sous SQL*Plus et qui donnent des informations sur la base courante.
Autres articles sur SQLcl : http://dbaoraclesql.canalblog.com/archives/sqlcl/index.html
Points d'attention
N/A.
Base de tests
Une base Oracle 19c multi-tenants.
Exemples
============================================================================================
SQLcl : les nouvelles options de la commande SHOW
============================================================================================
Attention, la commande pour lancer cet utilitaire est sqlui et non pas sqlcl; allez savoir pourquoi...
[oracle@localhost ~]$ sqlcl
bash: sqlcl: command not found...
[oracle@localhost ~]$ sqlui HR
SQLcl: Release 19.1 Production on Tue Mar 16 05:50:24 2021
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Password? (**********?) **
Last Successful login time: Tue Mar 16 2021 05:50:27 -04:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
Que dit l'aide sur la commande SHOW?
SQL> help show
SHOW
----
Shows the value of a SQLcl system variable, or the current SQLcl environment. SHOW SGA requires a DBA privileged login.
SHO[W] option
where option represents one of the following terms or clauses:
system_variable
ALL
BTI[TLE]
CON_ID - Show the ID of the database connected
CON_NAME - Show the current database connected
CONNECTION - Show the current connection details
EDITION - Show the current enabled edition
ENCODING - Show the encoding which is set for the client
ENCODINGS - Show the available encodings for the client
ERR[ORS] [{FUNCTION | PROCEDURE | PACKAGE | PACKAGE BODY | TRIGGER
| VIEW | TYPE | TYPE BODY | DIMENSION | JAVA CLASS} [schema.]name]
INSTANCE - Show the instance of the database that the client is connected to
JAVA - Java JRE properties, including, java location, version and platform
JDBC - Connection details including versions (of driver and database) and URL
LNO
NLS - Show NLS parameters set for the current session
PARAMETERS [parameter_name]
PDBS
PNO
RECYC[LEBIN] [original_name]
REL[EASE]
REPF[OOTER]
REPH[EADER]
SGA
SPOO[L]
SPPARAMETERS [parameter_name]
SQLCODE
T2METRICDATA - Set metrics for Telemetry (T2) system
TNS - Location of tnsnames.ora and list of aliases
TTI[TLE]
USER
VERSION - Show the version of SQLcl
SHOW TNS
Location of tnsnames.ora and list of aliases.
Nouveau paramètre SQLcl.
Trois choses sont affichées avec cette commande :
- les répertoires où Oracle va chercher le tnsnames.ora
- le répertoire où Oracle a trouvé le tnsnames.ora
- les entrées du tnsnames.ora
SQL> show tns
TNS Lookup locations
--------------------
1. USER Home dir
/home/oracle
2. ORACLE_HOME
/u01/app/oracle/product/version/db_1/network/admin
Location used:
-------------
/u01/app/oracle/product/version/db_1/network/admin
Available TNS Entries
---------------------
ORCL
ORCLCDB
SHOW INSTANCE
Show the instance of the database that the client is connected to.
Pas un nouveau paramètre SQLcl mais plus d'infos qu'avec SQL*Plus.
Attention, le nom de l'instance n'est pas le nom de la base à laquelle vous êtes connecté, pour cela c'est l'option PDBS qu'il faut utiliser (voir ci-dessous).
SQL> show instance
USERNAME HR
INSTANCE_NAME orclcdb
HOST_NAME localhost.localdomain
SID 53
VERSION 19.0.0.0.0
STARTUP_DAY 20210222
La version SQL*Plus est plus avare en informations.
SQL> show instance
instance "local"
SHOW PDBS
Pour voir le nom de la base à laquelle vous êtes connecté.
Nouveau paramètre SQLcl.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
_________ ___________ _____________ _____________
3 ORCL READ WRITE NO
SHOW CON_NAME et USER
Les deux paramètres suivants existent aussi sous SQL*Plus depuis la nouvelle architecture multi-tenants mais c'est bien des rappeler dans ce genre d'article. A noter que si show con_name est très pratique pour savoir où on est connecté, je vous déconseille le show con_id qui est plus dur à interpréter : quand il vaut 0 ou 1, vous ne serez pas plus avancé... surtout si votre base n'est pas en multi-tenants.
SQL> show con_name
CON_NAME
------------------------------
ORCL
SQL> show user
USER is "HR"
SHOW CONNECTION
Show the current connection details
Nouveau paramètre SQLcl.
PRELIMAUTH concerne une connexion spéciale à la base, dite connexion prelim, dans le cas où la base n'est plus accessible (elle est hung ou freeze).
SQL> show connection
CONNECTION:
HR@jdbc:oracle:oci8:@ORCL
CONNECTION_IDENTIFIER:
ORCL
CONNECTION_DB_VERSION:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
NOLOG:
false
PRELIMAUTH:
false
SHOW ENCODING
Show the encoding which is set for the client
Nouveau paramètre SQLcl.
SQL> show encoding
Encoding:UTF-8
SHOW NLS
Show NLS parameters set for the current session
Nouveau paramètre SQLcl.
SQL> show nls
DB_TIMEZONE +00:00
NLS_CALENDAR GREGORIAN
NLS_CHARACTERSET AL32UTF8
NLS_COMP BINARY
NLS_CURRENCY $
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_DUAL_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_LANGUAGE AMERICAN
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
NLS_NUMERIC_CHARACTERS .,
NLS_SORT BINARY
NLS_TERRITORY AMERICA
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
SESSION_TIMEZONE America/New_York
SESSION_TIMEZONE_OFFSET -04:00