Consultas útiles Oracle parte 1 de 2

¿Quién no tiene su chuleta de consultas útiles que se suelen utilizar en el día a día, y en nuestras aventuras y desventuras con un BBDD  Oracle?

En este pequeño  post vamos  a ver un resumen de consultas SQL de Oracle,  basadas  la mayoría sobre las vistas del diccionario de Oracle,  y animo a todo el que quiera añadir otras que considere de utilidad a responder el post publicando las suyas, a ver si entre todos creamos un repositorio que podamos consultar desde cualquier lugar para facilitarnos la vida, o sacarnos de algún que otro apuro.

 

 

Consulta Oracle SQL sobre la vista que muestra el estado de la base de datos

En primer lugar veamos  uan simple consulta muy general para    ver como esta la BBDD  en el momento de la consulta  .

 

La  consulta es bastante sencilla:

select * from v$instance




Con esta interesante consulta podemos  ver el numero de la instancia y su sombre , la version de BBDD, el tiempo desde el que esta arrancada la BBDD y es  estado en general  de la BBDD

Esa vista es tan interesante que de hecho se usa otra consulta Oracle SQL que muestra si la base de datos está abierta  :

select status from v$instance






Consulta Oracle SQL sobre la vista que muestra los parámetros generales de Oracle

Si queremos leer unos  258 parámetros generales de una BBDD  Oracle v 9   , en efecto  podemos recuperar  sus valores directamente con la siguiente consulta:

select * from v$system_parameter






De esta  consulta podemos obtener valores muy  interesantes ,como podemos ver en la pantalla anterior. De hecho basada en esa vista , podemos recuperar  algunos  de los mas importantes   simplemente filtrando  por el campo «name«.   A continuación   aquí algunas de las mas destacadas: 

  • Si solo queremos  conocer la Versión de Oracle   lanzaremos esta consulta

select value from v$system_parameter where name = ‘compatible’

  • Si solo queremos  conocer  la Ubicación y nombre del fichero spfile

select value from v$system_parameter where name = ‘spfile’

  • Esta Consulta Oracle SQL es  para conocer la Ubicación y número de ficheros de control

select value from v$system_parameter where name = ‘control_files

 
  • Y por ultimo una consulta Oracle SQL para conocer el Nombre de la base de datos

select value from v$system_parameter where name = ‘db_name’

 

 

Una vista muy parecida  a v$system  es la vista  v$parameter  ,la cual nos permite ver parámetros de Oracle, valor actual y su descripción

 

SELECT v.name, v.value value, decode(ISSYS_MODIFIABLE, 'DEFERRED',

'TRUE', 'FALSE') ISSYS_MODIFIABLE, decode(v.isDefault, 'TRUE', 'YES',

'FALSE', 'NO') "DEFAULT", DECODE(ISSES_MODIFIABLE, 'IMMEDIATE',

'YES','FALSE', 'NO', 'DEFERRED', 'NO', 'YES') SES_MODIFIABLE,

DECODE(ISSYS_MODIFIABLE, 'IMMEDIATE', 'YES', 'FALSE', 'NO',

'DEFERRED', 'YES','YES') SYS_MODIFIABLE , v.description

FROM V$PARAMETER v

WHERE name not like 'nls%' ORDER BY 1


 




Consulta Oracle SQL sobre la vista que muestra las conexiones actuales a Oracle


Ahora  vamos   a ver la vista v$session . La vista V$SESSION es la base de toda la información relacionada con el estado actual del sistema:

  • ¿Cuántas sesiones hay actualmente corriendo en la base de datos?
  • ¿Qué consulta se está ejecutando?
  • ¿Cuánto tardan en ejecutarse estas consultas?
 V$SESSION es el primer lugar cuando DBA comienza a buscar información relacionada con el rendimiento  e información de la ejecución de las consultas, un DBA puede llegar a consultar un centenar de veces al día esta vista, así que puede ser interesante inspeccionar su contenido


 Como casi todas las consultas que vamos a ver ,para visualizar  el resultado de esta consulta  es necesario entrar con privilegios de administrador


Veamos una consulta general para obtener los usuarios conectados a la BBDD;

select osuser, username, machine, program from v$session order by osuser




También sobre esa misma vista podemos lanzar una consulta  que muestra el número de conexiones actuales a Oracle    agrupado por aplicación que realiza la  conexión:

 

select program Aplicacion, count(program) Numero_Sesiones

from v$session

group by program

order by Numero_Sesiones desc



Otra consulta interesante  basada en la vista v$session ,  es la siguiente que  muestra los usuarios de Oracle conectados y el número de sesiones por usuario:

select username Usuario_Oracle, count(username) Numero_Sesiones

from v$session

group by username

order by Numero_Sesiones desc






Cada vez que se conecta a los datos se crea una sesión en la base de datos para realizar sus operaciones. Un DBA puede ver fácilmente esto consultando la vista de sistema V$SESSION.

Para ello  podemos lanzar  la siguiente consulta (en el caso del entorno RAC, DBA debe utilizar GV$SESSION en lugar de V$SESSION).

selectcount(*),type fromv$sessiongroup by type;

 

 

Puede utilizar la consulta siguiente para identificar qué usuario está creando un número alto de sesiones.

select SID,USERNAME,COMMAND,PROCESS,TERMINAL,PROGRAM from v$session where type=’USER’;

 

 

 

  • SID es la ID de la sesión, USERNAME es el nombre del usuario de la base de datos.
  • Process es el número de proceso. 
  • Terminal es el nombre del sistema que esta ejecutando la consulta. 
  • Program muestra el nombre del programa que esta usando la consulta.



Consultas  sobre el Diccionario de datos

Esta es una de las consultas mas potentes pues incluye todas las vistas y tablas de la Base de Datos. segun la version de la BBDD Oracle  puede llegar la consulta  a lanzar el resultados de unss 500 tablas.

Simplemente    para obtenerla podemos lanzar la siguiente consulta:

select * from dictionary

 

Este es resultado obtenido  lanzado  contra una BBDD Oracle 9:

 

TABLE_NAME COMMENTS
ALL_ALL_TABLES Description of all object and relational tables accessible to the user
ALL_APPLY Details about each apply process that dequeues from the queue visible to the current user
ALL_APPLY_CONFLICT_COLUMNS Details about conflict resolution on tables visible to the current user
ALL_APPLY_DML_HANDLERS Details about the dml handler on tables visible to the current user
ALL_APPLY_ERROR Error transactions that were generated after dequeuing from the queue visible to the current user
ALL_APPLY_KEY_COLUMNS Alternative key columns for a STREAMS table visible to the current user
ALL_APPLY_PARAMETERS Details about parameters of each apply process that dequeues from the queue visible to the current user
ALL_APPLY_PROGRESS Information about the progress made by the apply process that dequeues from the queue visible to the current user
ALL_ARGUMENTS Arguments in object accessible to the user
ALL_ASSOCIATIONS All associations available to the user
ALL_AUDIT_POLICIES All fine grained auditing policies in the database
ALL_BASE_TABLE_MVIEWS All materialized views with log(s) in the database that the user can see
ALL_CAPTURE Details about each capture process that stores the captured changes in a queue visible to the current user
ALL_CAPTURE_PARAMETERS Details about parameters for each capture process that stores the captured changes in a queue visible to the current user
ALL_CAPTURE_PREPARED_DATABASE Is the local database prepared for instantiation?
ALL_CAPTURE_PREPARED_SCHEMAS All user schemas at the local database that are prepared for instantiation
ALL_CAPTURE_PREPARED_TABLES All tables visible to the current user that are prepared for instantiation
ALL_CATALOG All tables, views, synonyms, sequences accessible to the user
ALL_CLUSTERS Description of clusters accessible to the user
ALL_CLUSTER_HASH_EXPRESSIONS Hash functions for all accessible clusters
ALL_COLL_TYPES Description of named collection types accessible to the user
ALL_COL_COMMENTS Comments on columns of accessible tables and views
ALL_COL_PRIVS Grants on columns for which the user is the grantor, grantee, owner,
 or an enabled role or PUBLIC is the grantee
ALL_COL_PRIVS_MADE Grants on columns for which the user is owner or grantor
ALL_COL_PRIVS_RECD Grants on columns for which the user, PUBLIC or enabled role is the grantee
ALL_CONSTRAINTS Constraint definitions on accessible tables
ALL_CONS_COLUMNS Information about accessible columns in constraint definitions
ALL_CONS_OBJ_COLUMNS List of types an object column or attribute is constrained to in the tables accessible to the user
ALL_CONTEXT Description of all active context namespaces under the current session
ALL_DB_LINKS Database links accessible to the user
ALL_DEF_AUDIT_OPTS Auditing options for newly created objects
ALL_DEPENDENCIES Dependencies to and from objects accessible to the user
ALL_DIMENSIONS Description of the dimension objects accessible to the DBA
ALL_DIM_ATTRIBUTES Representation of the relationship between a dimension level and
 a functionally dependent column
ALL_DIM_CHILD_OF Representaion of a 1:n hierarchical relationship between a pair of levels in
 a dimension
ALL_DIM_HIERARCHIES Representation of a dimension hierarchy
ALL_DIM_JOIN_KEY Representation of a join between two dimension tables. 
ALL_DIM_LEVELS Description of dimension levels visible to DBA
ALL_DIM_LEVEL_KEY Representations of columns of a dimension level
ALL_DIRECTORIES Description of all directories accessible to the user
ALL_ERRORS Current errors on stored objects that user is allowed to create
ALL_EVALUATION_CONTEXTS rule evaluation contexts seen by user
ALL_EVALUATION_CONTEXT_TABLES tables in all rule evaluation contexts seen by the user
ALL_EVALUATION_CONTEXT_VARS variables in all rule evaluation contexts seen by the user
ALL_EXTERNAL_LOCATIONS Description of the external tables locations accessible to the user
ALL_EXTERNAL_TABLES Description of the external tables accessible to the user
ALL_INDEXES Descriptions of indexes on tables accessible to the user
ALL_INDEXTYPES All indextypes available to the user
ALL_INDEXTYPE_COMMENTS Comments for user-defined indextypes
ALL_INDEXTYPE_OPERATORS All operators available to the user
ALL_IND_COLUMNS COLUMNs comprising INDEXes on accessible TABLES
ALL_IND_EXPRESSIONS FUNCTIONAL INDEX EXPRESSIONs on accessible TABLES
ALL_IND_PARTITIONS
ALL_IND_SUBPARTITIONS
ALL_INTERNAL_TRIGGERS Description of the internal triggers on the tables accessible to the user
ALL_JOIN_IND_COLUMNS Join Index columns comprising the join conditions
ALL_LIBRARIES Description of libraries accessible to the user
ALL_LOBS Description of LOBs contained in tables accessible to the user
ALL_LOB_PARTITIONS
ALL_LOB_SUBPARTITIONS
ALL_LOB_TEMPLATES
ALL_LOG_GROUPS Log group definitions on accessible tables
ALL_LOG_GROUP_COLUMNS Information about columns in log group definitions
ALL_METHOD_PARAMS Description of method parameters of types accessible
to the user
ALL_METHOD_RESULTS Description of method results of types accessible
to the user
ALL_MVIEWS All materialized views in the database
ALL_MVIEW_AGGREGATES Description of the materialized view aggregates accessible to the user
ALL_MVIEW_ANALYSIS Description of the materialized views accessible to the user
ALL_MVIEW_DETAIL_RELATIONS Description of the materialized view detail tables accessible to the user
ALL_MVIEW_JOINS Description of a join between two columns in the
WHERE clause of a materialized view accessible to the user
ALL_MVIEW_KEYS Description of the columns that appear in the GROUP BY
list of a materialized view accessible to the user
ALL_MVIEW_LOGS All materialized view logs in the database that the user can see
ALL_MVIEW_REFRESH_TIMES Materialized views and their last refresh times  for each master table that the user can look at
ALL_NESTED_TABLES Description of nested tables in tables accessible to the user
ALL_OBJECTS Objects accessible to the user
ALL_OBJECT_TABLES Description of all object tables accessible to the user
ALL_OBJ_COLATTRS Description of object columns and attributes contained in the tables accessible to the user
ALL_OPANCILLARY All ancillary operators available to the user
ALL_OPARGUMENTS All arguments of the operators available to the user
ALL_OPBINDINGS All binding functions for operators available to the user
ALL_OPERATORS All operators available to the user
ALL_OPERATOR_COMMENTS Comments for user-defined operators
ALL_PARTIAL_DROP_TABS All tables with patially dropped columns accessible to the user
ALL_PART_COL_STATISTICS
ALL_PART_HISTOGRAMS
ALL_PART_INDEXES
ALL_PART_KEY_COLUMNS
ALL_PART_LOBS
ALL_PART_TABLES
ALL_PENDING_CONV_TABLES All tables accessible to the user which are not upgraded to the latest type version
ALL_POLICIES All policies for objects if the user has system privileges or owns the objects
ALL_POLICY_CONTEXTS All policy driving context defined for all synonyms, tables, or views accessable to the user
ALL_POLICY_GROUPS All policy groups defined for any synonym, table or view accessable to the user
ALL_PROBE_OBJECTS
ALL_PROCEDURES Description of all procedures available to the user
ALL_PROPAGATION Streams propagation seen by the user
ALL_PUBLISHED_COLUMNS
ALL_QUEUES All queues accessible to the user
ALL_QUEUE_PUBLISHERS
ALL_QUEUE_TABLES All queue tables accessible to the user
ALL_REFRESH All the refresh groups that the user can touch
ALL_REFRESH_CHILDREN All the objects in refresh groups, where the user can touch the group
ALL_REFRESH_DEPENDENCIES Description of the detail tables that materialized views depend on for
refresh
ALL_REFS Description of REF columns contained in tables accessible to the user
ALL_REGISTERED_MVIEWS Remote materialized views of local tables that the user can see
ALL_REGISTERED_SNAPSHOTS Remote snapshots of local tables that the user can see
ALL_REGISTRY_BANNERS
ALL_REPAUDIT_ATTRIBUTE Information about attributes automatically maintained for replication
ALL_REPAUDIT_COLUMN Information about columns in all shadow tables for replicated tables which are accessible to the user
ALL_REPCAT
ALL_REPCATLOG Information about asynchronous administration requests
ALL_REPCOLUMN Replicated top-level columns (table) sorted alphabetically in ascending order
ALL_REPCOLUMN_GROUP All column groups of replicated tables which are accessible to the user
ALL_REPCONFLICT All conflicts with available resolutions for user’s replicated tables
ALL_REPDDL Arguments that do not fit in a single repcat log record
ALL_REPFLAVORS Flavors defined for replicated object groups
ALL_REPFLAVOR_COLUMNS Replicated columns in flavors
ALL_REPFLAVOR_OBJECTS Replicated objects in flavors
ALL_REPGENERATED Objects generated to support replication
ALL_REPGENOBJECTS Objects generated to support replication
ALL_REPGROUP Information about replicated object groups
ALL_REPGROUPED_COLUMN Columns in the all column groups of replicated tables which are accessible to the user
ALL_REPGROUP_PRIVILEGES Information about users who are registered for object group privileges
ALL_REPKEY_COLUMNS Primary columns for a table using column-level replication
ALL_REPOBJECT Information about replicated objects
ALL_REPPARAMETER_COLUMN All columns used for resolving conflicts in replicated tables which are accessible to the user
ALL_REPPRIORITY Values and their corresponding priorities in all priority groups which are accessible to the user
ALL_REPPRIORITY_GROUP Information about all priority groups which are accessible to the user
ALL_REPPROP Propagation information about replicated objects
ALL_REPRESOLUTION Description of all conflict resolutions for replicated tables which are accessible to the user
ALL_REPRESOLUTION_METHOD All conflict resolution methods accessible to the user
ALL_REPRESOLUTION_STATISTICS Statistics for conflict resolutions for replicated tables which are accessible to the user
ALL_REPRESOL_STATS_CONTROL Information about statistics collection for conflict resolutions for replicated tables which are accessible to the user
ALL_REPSCHEMA N-way replication information
ALL_REPSITES N-way replication information
ALL_RULES Rules seen by the user
ALL_RULESETS Rulesets seen by the user: maintained for backward compatibility
ALL_RULE_SETS Rule sets seen by the user
ALL_RULE_SET_RULES Rules in all rule sets seen by the user
ALL_SECONDARY_OBJECTS All secondary objects for domain indexes
ALL_SEQUENCES Description of SEQUENCEs accessible to the user
ALL_SNAPSHOTS Snapshots the user can access
ALL_SNAPSHOT_LOGS All snapshot logs in the database that the user can see
ALL_SOURCE Current source on stored objects that user is allowed to create
ALL_SOURCE_TABLES
ALL_SOURCE_TAB_COLUMNS
ALL_SQLJ_TYPES Description of types accessible to the user
ALL_SQLJ_TYPE_ATTRS Description of attributes of types accessible to the user
ALL_SQLJ_TYPE_METHODS Description of methods of types accessible to the user
ALL_STORED_SETTINGS Parameter settings for objects accessible to the user
ALL_STREAMS_GLOBAL_RULES Global rules created on the streams capture/apply/propagation process that interact with the queue visible to the current user
ALL_STREAMS_SCHEMA_RULES Rules created by streams administrative APIs on all user schemas
ALL_STREAMS_TABLE_RULES Rules created by streams administrative APIs on tables visible to the current user
ALL_SUBPARTITION_TEMPLATES
ALL_SUBPART_COL_STATISTICS
ALL_SUBPART_HISTOGRAMS
ALL_SUBPART_KEY_COLUMNS
ALL_SUBSCRIBED_COLUMNS
ALL_SUBSCRIBED_TABLES
ALL_SUBSCRIPTIONS
ALL_SUMDELTA Direct path load entries accessible to the user
ALL_SUMMARIES Description of the summaries accessible to the user
ALL_SYNONYMS All synonyms accessible to the user
ALL_TABLES Description of relational tables accessible to the user
ALL_TAB_COLS Columns of user’s tables, views and clusters
ALL_TAB_COLUMNS Columns of user’s tables, views and clusters
ALL_TAB_COL_STATISTICS Columns of user’s tables, views and clusters
ALL_TAB_COMMENTS Comments on tables and views accessible to the user
ALL_TAB_HISTOGRAMS Histograms on columns of all tables visible to user
ALL_TAB_MODIFICATIONS Information regarding modifications to tables
ALL_TAB_PARTITIONS
ALL_TAB_PRIVS Grants on objects for which the user is the grantor, grantee, owner,
 or an enabled role or PUBLIC is the grantee
ALL_TAB_PRIVS_MADE User’s grants and grants on user’s objects
ALL_TAB_PRIVS_RECD Grants on objects for which the user, PUBLIC or enabled role is the grantee
ALL_TAB_SUBPARTITIONS
ALL_TRIGGERS Triggers accessible to the current user
ALL_TRIGGER_COLS Column usage in user’s triggers or in triggers on user’s tables
ALL_TYPES Description of types accessible to the user
ALL_TYPE_ATTRS Description of attributes of types accessible to the user
ALL_TYPE_METHODS Description of methods of types accessible to the user
ALL_TYPE_VERSIONS Description of each type version accessible to the user
ALL_UNUSED_COL_TABS All tables with unused columns accessible to the user
ALL_UPDATABLE_COLUMNS Description of all updatable columns
ALL_USERS Information about all users of the database
ALL_USTATS All statistics
ALL_VARRAYS Description of varrays in tables accessible to the user
ALL_VIEWS Description of views accessible to the user
USER_ALL_TABLES Description of all object and relational tables owned by the user’s
USER_AQ_AGENT_PRIVS
USER_ARGUMENTS Arguments in object accessible to the user
USER_ASSOCIATIONS All assocations defined by the user
USER_ATTRIBUTE_TRANSFORMATIONS
USER_AUDIT_OBJECT Audit trail records for statements concerning objects, specifically: table, cluster, view, index, sequence,  [public] database link, [public] synonym, procedure, trigger, rollback segment, tablespace, role, user
USER_AUDIT_POLICIES All fine grained auditing policies for objects in user schema
USER_AUDIT_SESSION All audit trail records concerning CONNECT and DISCONNECT
USER_AUDIT_STATEMENT Audit trail records concerning  grant, revoke, audit, noaudit and alter system
USER_AUDIT_TRAIL Audit trail entries relevant to the user
USER_AWS Analytic Workspaces owned by the user
USER_AW_PS Pagespaces in Analytic Workspaces owned by the user
USER_BASE_TABLE_MVIEWS All materialized views with log(s) owned by the user in the database
USER_CATALOG Tables, Views, Synonyms and Sequences owned by the user
USER_CLUSTERS Descriptions of user’s own clusters
USER_CLUSTER_HASH_EXPRESSIONS Hash functions for the user’s hash clusters
USER_CLU_COLUMNS Mapping of table columns to cluster columns
USER_COLL_TYPES Description of the user’s own named collection types
USER_COL_COMMENTS Comments on columns of user’s tables and views
USER_COL_PRIVS Grants on columns for which the user is the owner, grantor or grantee
USER_COL_PRIVS_MADE All grants on columns of objects owned by the user
USER_COL_PRIVS_RECD Grants on columns for which the user is the grantee
USER_CONSTRAINTS Constraint definitions on user’s own tables
USER_CONS_COLUMNS Information about accessible columns in constraint definitions
USER_CONS_OBJ_COLUMNS List of types an object column or attribute is constrained to in the tables owned by the user
USER_DB_LINKS Database links owned by the user
USER_DEPENDENCIES Dependencies to and from a users objects
USER_DIMENSIONS Description of the dimension objects accessible to the DBA
USER_DIM_ATTRIBUTES Representation of the relationship between a dimension level and
 a functionally dependent column
USER_DIM_CHILD_OF Representaion of a 1:n hierarchical relationship between a pair of levels in
 a dimension
USER_DIM_HIERARCHIES Representation of a dimension hierarchy
USER_DIM_JOIN_KEY Representation of a join between two dimension tables. 
USER_DIM_LEVELS Description of dimension levels visible to DBA
USER_DIM_LEVEL_KEY Representations of columns of a dimension level
USER_ERRORS Current errors on stored objects owned by the user
USER_EVALUATION_CONTEXTS rule evaluation contexts owned by user
USER_EVALUATION_CONTEXT_TABLES tables in user rule evaluation contexts
USER_EVALUATION_CONTEXT_VARS variables in user rule evaluation contexts
USER_EXTENTS Extents comprising segments owned by the user
USER_EXTERNAL_LOCATIONS Description of the user’s external tables locations
USER_EXTERNAL_TABLES Description of the user’s own external tables
USER_FREE_SPACE Free extents in tablespaces accessible to the user
USER_INDEXES Description of the user’s own indexes
USER_INDEXTYPES All user indextypes
USER_INDEXTYPE_COMMENTS Comments for user-defined indextypes
USER_INDEXTYPE_OPERATORS All user indextype operators
USER_IND_COLUMNS COLUMNs comprising user’s INDEXes and INDEXes on user’s TABLES
USER_IND_EXPRESSIONS Functional index expressions in user’s indexes and indexes on user’s tables
USER_IND_PARTITIONS
USER_IND_SUBPARTITIONS
USER_INTERNAL_TRIGGERS Description of the internal triggers on the user’s own tables
USER_JOBS All jobs owned by this user
USER_JOIN_IND_COLUMNS Join Index columns comprising the join conditions
USER_LIBRARIES Description of the user’s own libraries
USER_LOBS Description of the user’s own LOBs contained in the user’s own tables
USER_LOB_PARTITIONS
USER_LOB_SUBPARTITIONS
USER_LOB_TEMPLATES
USER_LOG_GROUPS Log group definitions on user’s own tables
USER_LOG_GROUP_COLUMNS Information about columns in log group definitions
USER_METHOD_PARAMS Description of method parameters of the user’s own types
USER_METHOD_RESULTS Description of method results of the user’s own types
USER_MVIEWS All materialized views in the database
USER_MVIEW_AGGREGATES Description of the materialized view aggregates created by the user
USER_MVIEW_ANALYSIS Description of the materialized views created by the user
USER_MVIEW_DETAIL_RELATIONS Description of the materialized view detail tables of the materialized
views created by the user
USER_MVIEW_JOINS Description of a join between two columns in the
WHERE clause of a materialized view created by the user
USER_MVIEW_KEYS Description of the columns that appear in the GROUP BY
list of a materialized view  created by the user
USER_MVIEW_LOGS All materialized view logs owned by the user
USER_MVIEW_REFRESH_TIMES Materialized views and their last refresh times for each master table that the user can look at
USER_NESTED_TABLES Description of nested tables contained in the user’s own tables
USER_OBJECTS Objects owned by the user
USER_OBJECT_SIZE Sizes, in bytes, of various pl/sql objects
USER_OBJECT_TABLES Description of the user’s own object tables
USER_OBJ_AUDIT_OPTS Auditing options for user’s own tables and views
USER_OBJ_COLATTRS Description of object columns and attributes contained in tables owned by the user
USER_OPANCILLARY All ancillary opertors defined by user
USER_OPARGUMENTS All operator arguments of operators defined by user
USER_OPBINDINGS All binding functions or methods on operators defined by the user
USER_OPERATORS All user operators
USER_OPERATOR_COMMENTS Comments for user-defined operators
USER_OUTLINES Stored outlines owned by the user
USER_OUTLINE_HINTS Hints stored in outlines owned by the user
USER_PARTIAL_DROP_TABS User tables with unused columns
USER_PART_COL_STATISTICS
USER_PART_HISTOGRAMS
USER_PART_INDEXES
USER_PART_KEY_COLUMNS
USER_PART_LOBS
USER_PART_TABLES
USER_PASSWORD_LIMITS Display password limits of the user
USER_PENDING_CONV_TABLES All user’s tables which are not upgraded to the latest type version
USER_POLICIES All row level security policies for synonyms, tables, or views owned by the user
USER_POLICY_CONTEXTS All policy driving context defined for synonyms, tables, or views in current schema
USER_POLICY_GROUPS All policy groups defined for any synonym, table, or view
USER_PROCEDURES Description of the users own procedures
USER_PROXIES Description of connections the user is allowed to proxy
USER_PUBLISHED_COLUMNS
USER_QUEUES All queues owned by the user
USER_QUEUE_PUBLISHERS
USER_QUEUE_SCHEDULES
USER_QUEUE_TABLES All queue tables created by the user
USER_REFRESH All the refresh groups
USER_REFRESH_CHILDREN All the objects in refresh groups, where the user owns the refresh group
USER_REFS Description of the user’s own REF columns contained in the user’s own tables
USER_REGISTERED_MVIEWS Remote materialized views of local tables currently using logs owned by the user
USER_REGISTERED_SNAPSHOTS Remote snapshots of local tables currently using logs owned by the user
USER_REGISTRY
USER_REPAUDIT_ATTRIBUTE Information about attributes automatically maintained for replication
USER_REPAUDIT_COLUMN Information about columns in all shadow tables for user’s replicated tables
USER_REPCAT
USER_REPCATLOG Information about the current user’s asynchronous administration requests
USER_REPCOLUMN Replicated columns for the current user’s table in ascending order
USER_REPCOLUMN_GROUP All column groups of user’s replicated tables
USER_REPCONFLICT
USER_REPDDL Arguments that do not fit in a single repcat log record
USER_REPFLAVORS Flavors current user created for replicated object groups
USER_REPFLAVOR_COLUMNS Replicated columns from current user’s tables in flavors
USER_REPFLAVOR_OBJECTS Replicated user objects in flavors
USER_REPGENERATED Objects generated for the current user to support replication
USER_REPGENOBJECTS Objects generated for the current user to support replication
USER_REPGROUP Replication information about the current user
USER_REPGROUPED_COLUMN Columns in the all column groups of user’s replicated tables
USER_REPGROUP_PRIVILEGES Information about users who are registered for object group privileges
USER_REPKEY_COLUMNS Primary columns for a table using column-level replication
USER_REPOBJECT Replication information about the current user’s objects
USER_REPPARAMETER_COLUMN All columns used for resolving conflicts in user’s replicated tables
USER_REPPRIORITY Values and their corresponding priorities in user’s priority groups
USER_REPPRIORITY_GROUP Information about user’s priority groups
USER_REPPROP Propagation information about the current user’s objects
USER_REPRESOLUTION Description of all conflict resolutions for user’s replicated tables
USER_REPRESOLUTION_METHOD All conflict resolution methods accessible to the user
USER_REPRESOLUTION_STATISTICS Statistics for conflict resolutions for user’s replicated tables
USER_REPRESOL_STATS_CONTROL Information about statistics collection for conflict resolutions for user’s replicated tables
USER_REPSCHEMA N-way replication information about the current user
USER_REPSITES N-way replication information about the current user
USER_RESOURCE_LIMITS Display resource limit of the user
USER_RESUMABLE Resumable session information for current user
USER_ROLE_PRIVS Roles granted to current user
USER_RSRC_CONSUMER_GROUP_PRIVS Switch privileges for consumer groups for the user
USER_RSRC_MANAGER_SYSTEM_PRIVS system privileges for the resource manager for the user
USER_RULES Rules owned by the user
USER_RULESETS Rulesets owned by the user: maintained for backward compatibility
USER_RULE_SETS Rule sets owned by the user
USER_RULE_SET_RULES Rules in user rule sets
USER_SECONDARY_OBJECTS All secondary objects for domain indexes
USER_SEGMENTS Storage allocated for all database segments
USER_SEQUENCES Description of the user’s own SEQUENCEs
USER_SNAPSHOTS Snapshots the user can look at
USER_SNAPSHOT_LOGS All snapshot logs owned by the user
USER_SOURCE Source of stored objects accessible to the user
USER_SOURCE_TABLES
USER_SOURCE_TAB_COLUMNS
USER_SQLJ_TYPES Description of the user’s own types
USER_SQLJ_TYPE_ATTRS Description of attributes of the user’s own types
USER_SQLJ_TYPE_METHODS Description of methods of the user’s own types
USER_STORED_SETTINGS Parameter settings for objects owned by the user
USER_SUBPARTITION_TEMPLATES
USER_SUBPART_COL_STATISTICS
USER_SUBPART_HISTOGRAMS
USER_SUBPART_KEY_COLUMNS
USER_SUBSCRIBED_COLUMNS
USER_SUBSCRIBED_TABLES
USER_SUBSCRIPTIONS
USER_SUMMARIES Description of the summaries created by the user
USER_SYNONYMS The user’s private synonyms
USER_SYS_PRIVS System privileges granted to current user
USER_TABLES Description of the user’s own relational tables
USER_TABLESPACES Description of accessible tablespaces
USER_TAB_COLS Columns of user’s tables, views and clusters
USER_TAB_COLUMNS Columns of user’s tables, views and clusters
USER_TAB_COL_STATISTICS Columns of user’s tables, views and clusters
USER_TAB_COMMENTS Comments on the tables and views owned by the user
USER_TAB_HISTOGRAMS Histograms on columns of user’s tables
USER_TAB_MODIFICATIONS Information regarding modifications to tables
USER_TAB_PARTITIONS
USER_TAB_PRIVS Grants on objects for which the user is the owner, grantor or grantee
USER_TAB_PRIVS_MADE All grants on objects owned by the user
USER_TAB_PRIVS_RECD Grants on objects for which the user is the grantee
USER_TAB_SUBPARTITIONS
USER_TRANSFORMATIONS
USER_TRIGGERS Triggers owned by the user
USER_TRIGGER_COLS Column usage in user’s triggers
USER_TS_QUOTAS Tablespace quotas for the user
USER_TYPES Description of the user’s own types
USER_TYPE_ATTRS Description of attributes of the user’s own types
USER_TYPE_METHODS Description of methods of the user’s own types
USER_TYPE_VERSIONS Description of each version of the user’s types
USER_UNUSED_COL_TABS User tables with unused columns
USER_UPDATABLE_COLUMNS Description of updatable columns
USER_USERS Information about the current user
USER_USTATS All statistics on tables or indexes owned by the user
USER_VARRAYS Description of varrays contained in the user’s own tables
USER_VIEWS Description of the user’s own views
AUDIT_ACTIONS Description table for audit trail action type codes.  Maps action type numbers to action type names
COLUMN_PRIVILEGES Grants on columns for which the user is the grantor, grantee, owner, or
 an enabled role or PUBLIC is the grantee
DATABASE_COMPATIBLE_LEVEL Database compatible parameter set via init.ora
DBMS_ALERT_INFO
DBMS_LOCK_ALLOCATED
DICTIONARY Description of data dictionary tables and views
DICT_COLUMNS Description of columns in data dictionary tables and views
DUAL  
GLOBAL_NAME global database name
INDEX_HISTOGRAM statistics on keys with repeat count
INDEX_STATS statistics on the b-tree
NLS_DATABASE_PARAMETERS Permanent NLS parameters of the database
NLS_INSTANCE_PARAMETERS NLS parameters of the instance
NLS_SESSION_PARAMETERS NLS parameters of the user session
RESOURCE_COST Cost for each resource
ROLE_ROLE_PRIVS Roles which are granted to roles
ROLE_SYS_PRIVS System privileges granted to roles
ROLE_TAB_PRIVS Table privileges granted to roles
SESSION_PRIVS Privileges which the user currently has set
SESSION_ROLES Roles which the user currently has enabled.
TABLE_PRIVILEGES Grants on objects for which the user is the grantor, grantee, owner,
 or an enabled role or PUBLIC is the grantee
ALL_HISTOGRAMS Synonym for ALL_TAB_HISTOGRAMS
ALL_JOBS Synonym for USER_JOBS
ALL_OUTLINES Synonym for USER_OUTLINES
ALL_OUTLINE_HINTS Synonym for USER_OUTLINE_HINTS
ALL_SNAPSHOT_REFRESH_TIMES Synonym for ALL_MVIEW_REFRESH_TIMES
CAT Synonym for USER_CATALOG
CLU Synonym for USER_CLUSTERS
COLS Synonym for USER_TAB_COLUMNS
DICT Synonym for DICTIONARY
GV$ACTIVE_INSTANCES Synonym for GV_$ACTIVE_INSTANCES
GV$ACTIVE_SESS_POOL_MTH Synonym for GV_$ACTIVE_SESS_POOL_MTH
GV$AW_CALC Synonym for GV_$AW_CALC
GV$AW_OLAP Synonym for GV_$AW_OLAP
GV$AW_SESSION_INFO Synonym for GV_$AW_SESSION_INFO
GV$BH Synonym for GV_$BH
GV$LOADISTAT Synonym for GV_$LOADISTAT
GV$LOADPSTAT Synonym for GV_$LOADPSTAT
GV$LOCK_ACTIVITY Synonym for GV_$LOCK_ACTIVITY
GV$MAX_ACTIVE_SESS_TARGET_MTH Synonym for GV_$MAX_ACTIVE_SESS_TARGET_MTH
GV$MLS_PARAMETERS Synonym for GV_$MLS_PARAMETERS
GV$NLS_PARAMETERS Synonym for GV_$NLS_PARAMETERS
GV$NLS_VALID_VALUES Synonym for GV_$NLS_VALID_VALUES
GV$OPTION Synonym for GV_$OPTION
GV$PARALLEL_DEGREE_LIMIT_MTH Synonym for GV_$PARALLEL_DEGREE_LIMIT_MTH
GV$PQ_SESSTAT Synonym for GV_$PQ_SESSTAT
GV$PQ_TQSTAT Synonym for GV_$PQ_TQSTAT
GV$QUEUEING_MTH Synonym for GV_$QUEUEING_MTH
GV$RSRC_CONSUMER_GROUP Synonym for GV_$RSRC_CONSUMER_GROUP
GV$RSRC_CONSUMER_GROUP_CPU_MTH Synonym for GV_$RSRC_CONSUME_GROUP_CPU_MTH
GV$RSRC_PLAN Synonym for GV_$RSRC_PLAN
GV$RSRC_PLAN_CPU_MTH Synonym for GV_$RSRC_PLAN_CPU_MTH
GV$SESSION_LONGOPS Synonym for GV_$SESSION_LONGOPS
GV$TEMPORARY_LOBS Synonym for GV_$TEMPORARY_LOBS
GV$TIMEZONE_NAMES Synonym for GV_$TIMEZONE_NAMES
GV$VERSION Synonym for GV_$VERSION
IND Synonym for USER_INDEXES
OBJ Synonym for USER_OBJECTS
SEQ Synonym for USER_SEQUENCES
SM$VERSION Synonym for SM_$VERSION
SYN Synonym for USER_SYNONYMS
TABS Synonym for USER_TABLES
USER_HISTOGRAMS Synonym for USER_TAB_HISTOGRAMS
USER_SNAPSHOT_REFRESH_TIMES Synonym for USER_MVIEW_REFRESH_TIMES
V$ACTIVE_INSTANCES Synonym for V_$ACTIVE_INSTANCES
V$ACTIVE_SESS_POOL_MTH Synonym for V_$ACTIVE_SESS_POOL_MTH
V$AW_CALC Synonym for V_$AW_CALC
V$AW_OLAP Synonym for V_$AW_OLAP
V$AW_SESSION_INFO Synonym for V_$AW_SESSION_INFO
V$BH Synonym for V_$BH
V$INSTANCE Synonym for V_$INSTANCE
V$LOADISTAT Synonym for V_$LOADISTAT
V$LOADPSTAT Synonym for V_$LOADPSTAT
V$LOCK_ACTIVITY Synonym for V_$LOCK_ACTIVITY
V$MAX_ACTIVE_SESS_TARGET_MTH Synonym for V_$MAX_ACTIVE_SESS_TARGET_MTH
V$MLS_PARAMETERS Synonym for V_$MLS_PARAMETERS
V$NLS_PARAMETERS Synonym for V_$NLS_PARAMETERS
V$NLS_VALID_VALUES Synonym for V_$NLS_VALID_VALUES
V$OPTION Synonym for V_$OPTION
V$PARALLEL_DEGREE_LIMIT_MTH Synonym for V_$PARALLEL_DEGREE_LIMIT_MTH
V$PARAMETER Synonym for V_$PARAMETER
V$PQ_SESSTAT Synonym for V_$PQ_SESSTAT
V$PQ_TQSTAT Synonym for V_$PQ_TQSTAT
V$QUEUEING_MTH Synonym for V_$QUEUEING_MTH
V$RSRC_CONSUMER_GROUP Synonym for V_$RSRC_CONSUMER_GROUP
V$RSRC_CONSUMER_GROUP_CPU_MTH Synonym for V_$RSRC_CONSUMER_GROUP_CPU_MTH
V$RSRC_PLAN Synonym for V_$RSRC_PLAN
V$RSRC_PLAN_CPU_MTH Synonym for V_$RSRC_PLAN_CPU_MTH
V$SESSION Synonym for V_$SESSION
V$SESSION_CONNECT_INFO Synonym for V_$SESSION_CONNECT_INFO
V$SESSION_LONGOPS Synonym for V_$SESSION_LONGOPS
V$SQLAREA Synonym for V_$SQLAREA
V$SQLTEXT Synonym for V_$SQLTEXT
V$SYSTEM_PARAMETER Synonym for V_$SYSTEM_PARAMETER
V$TEMPORARY_LOBS Synonym for V_$TEMPORARY_LOBS
V$TIMEZONE_NAMES Synonym for V_$TIMEZONE_NAMES
V$VERSION Synonym for V_$VERSION


Basándonos en el resultado  anterior  vamos a  ver algunas consultas sencillas ,por ejemplo:

  • Podemos lanzar  una consulta  que muestra los datos de una tabla especificada.En este caso filtramos  por todas las tablas que lleven la cadena «XXX»:  select * from ALL_ALL_TABLES where upper(table_name) like ‘%XXX%’
  • Consulta  que muestra las descripciones de los campos de una tabla especificada, peor en este caso con todas las tablas que lleven la cadena «XXX»: select * from ALL_COL_COMMENTS where upper(table_name) like ‘%XXX%’
  • Consulta para conocer las tablas propiedad del usuario actual: select * from user_tables
  • Consulta  para conocer todos los objetos propiedad del usuario conectado a Oracle  select * from user_catalog

 

 

🤞 No se pierda nuestro boletín mensual !es gratis!

¡No hacemos spam! Más información en nuestra política de privacidad

Un comentario sobre “Consultas útiles Oracle parte 1 de 2

Deja una respuesta