Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Vista SESSIONS_BY_USER
La vista INFORMATION_SCHEMA.SESSIONS_BY_USER contiene metadatos en tiempo real sobre las sesiones de BigQuery que creó el usuario actual en el proyecto actual.
Permisos necesarios
Para consultar la vista INFORMATION_SCHEMA.SESSIONS_BY_USER, necesitas el permiso bigquery.jobs.list de Identity and Access Management (IAM) para el proyecto.
Cada uno de los siguientes roles predefinidos de IAM incluye el permiso requerido:
Cuando consultas las vistas INFORMATION_SCHEMA.SESSIONS_BY_*, los resultados de la consulta contienen una fila para cada sesión de BigQuery.
La vista INFORMATION_SCHEMA.SESSIONS_BY_* tiene el siguiente esquema:
Nombre de la columna
Tipo de datos
Valor
creation_time
TIMESTAMP
Es la hora de creación de esta sesión (columna de partición).
La partición se basa en la hora UTC de esta marca de tiempo.
expiration_time
TIMESTAMP
Es la hora de vencimiento de esta sesión (columna de partición).
La partición se basa en la hora UTC de esta marca de tiempo.
is_active
BOOL
¿La sesión sigue activa? TRUE si la respuesta es sí, de lo contrario, FALSE.
last_modified_time
TIMESTAMP
Hora en la que se modificó la sesión por última vez (columna de partición).
La partición se basa en la hora UTC de esta marca de tiempo.
project_id
STRING
(Columna de agrupamiento en clústeres) ID del proyecto.
project_number
INTEGER
Es el número del proyecto.
session_id
STRING
ID de la sesión. Por ejemplo, bquxsession_1234.
user_email
STRING
Es la dirección de correo electrónico o la cuenta de servicio del usuario que ejecutó la sesión (columna de agrupamiento en clústeres).
Retención de datos
Esta vista contiene las sesiones que se están ejecutando y el historial de sesiones completadas en los últimos 180 días.
Permiso y sintaxis
Las consultas realizadas a esta vista deben incluir un calificador de región.
Si no especificas un calificador regional, los metadatos se recuperan de todas las regiones. En la siguiente tabla, se explica el permiso de la región para esta vista:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-03 (UTC)"],[[["\u003cp\u003eThe \u003ccode\u003eINFORMATION_SCHEMA.SESSIONS_BY_USER\u003c/code\u003e view provides real-time metadata about BigQuery sessions created by the current user within the current project.\u003c/p\u003e\n"],["\u003cp\u003eTo access this view, users need the \u003ccode\u003ebigquery.jobs.list\u003c/code\u003e IAM permission, which is included in the Project Viewer and BigQuery User roles.\u003c/p\u003e\n"],["\u003cp\u003eThis view's data is partitioned by \u003ccode\u003ecreation_time\u003c/code\u003e, \u003ccode\u003eexpiration_time\u003c/code\u003e, and \u003ccode\u003elast_modified_time\u003c/code\u003e columns, and clustered by \u003ccode\u003eproject_id\u003c/code\u003e and \u003ccode\u003euser_email\u003c/code\u003e, displaying information for each session in a row.\u003c/p\u003e\n"],["\u003cp\u003eThe view retains information on active sessions and historical data for sessions completed within the last 180 days.\u003c/p\u003e\n"],["\u003cp\u003eQueries on this view require a region qualifier and must be executed from the same region specified in the query, and the view name is case-sensitive.\u003c/p\u003e\n"]]],[],null,["# SESSIONS_BY_USER view\n=====================\n\nThe `INFORMATION_SCHEMA.SESSIONS_BY_USER` view contains real-time\nmetadata about BigQuery sessions created by the current user in\nthe current project.\n\nRequired permissions\n--------------------\n\nTo query the `INFORMATION_SCHEMA.SESSIONS_BY_USER` view, you need\nthe `bigquery.jobs.list` Identity and Access Management (IAM) permission for the project.\nEach of the following predefined IAM roles includes the\nrequired permission:\n\n- Project Viewer\n- BigQuery User\n\nFor more information about BigQuery permissions, see\n[Access control with IAM](/bigquery/docs/access-control).\n\nSchema\n------\n\nWhen you query the `INFORMATION_SCHEMA.SESSIONS_BY_*` views, the query results\ncontain one row for each BigQuery session.\n\nThe `INFORMATION_SCHEMA.SESSIONS_BY_*` view has the following schema:\n| **Note:** The underlying data is partitioned by the `creation_time` column and clustered by `project_id` and `user_email`.\n\nData retention\n--------------\n\nThis view contains currently running sessions and the history of sessions\ncompleted in the past 180 days.\n\nScope and syntax\n----------------\n\nQueries against this view must include a [region qualifier](/bigquery/docs/information-schema-intro#syntax).\nIf you do not specify a regional qualifier, metadata is retrieved from all\nregions. The following table explains the region scope for this view:\n\nReplace the following:\n\n- Optional: \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your Google Cloud project. If not specified, the default project is used.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: any [dataset region name](/bigquery/docs/locations). For example, ```region-us```.\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n | **Note:** You must use [a region qualifier](/bigquery/docs/information-schema-intro#region_qualifier) to query `INFORMATION_SCHEMA` views. The location of the query execution must match the region of the `INFORMATION_SCHEMA` view.\n\n\u003cbr /\u003e\n\nExample\n-------\n\nTo run the query against a project other than your default project, add the\nproject ID in the following format: \n\n```bash\n`PROJECT_ID`.`region-REGION_NAME`.INFORMATION_SCHEMA.SESSIONS_BY_USER\n```\nFor example, ```myproject`.`region-us`.INFORMATION_SCHEMA.SESSIONS_BY_USER``.\n\n\u003cbr /\u003e\n\nThe following example lists sessions that were created by the current user: \n\n```googlesql\nSELECT\n session_id,\n creation_time\nFROM\n `region-us`.INFORMATION_SCHEMA.SESSIONS_BY_USER\nWHERE\n creation_time \u003e= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY)\nORDER BY\n creation_time DESC;\n```\n| **Note:** `INFORMATION_SCHEMA` view names are case-sensitive.\n\nThe results should look like the following: \n\n```\n+-------------------------------------------------------------------------+\n| session_id | creation_time |\n+-------------------------------------------------------------------------+\n| CgwKCmZhbGl1LXRlc3QQARokMGQ5YWWYzZmE0YjhkMDBm | 2021-06-01 08:04:26 |\n| CgwKCmZhbGl1LXRlc3QQARokMDAzYjI0OWQtZTczwZjA1NDc2 | 2021-05-31 22:43:02 |\n+-------------------------------------------------------------------------+\n```"]]