Introduction to sessions
This guide describes how to enable, create, and track changes in a
BigQuery session. It is intended for users who are familiar with
BigQuery and
GoogleSQL.
You can capture your SQL activities in a BigQuery session.
Temporary tables, temporary functions, and variables can be used throughout the session to
interactively build one or more queries. Multiple sessions can be active at the
same time and the history for each session is saved. You can view the history
of a session for up to 20 days after the session is terminated.
Typical uses for a session include the following:
Maintain transient session data. Define variables and temporary tables
once and use them throughout the session.
Look up query history by session. If you want to keep track of a behavior
that happened at a particular time during the session, you can view the
history of changes that were made during the
session.
Create multi-statement transactions over multiple queries. Within a
session, you can begin a transaction, make changes, and view the temporary
result before deciding to commit or rollback. You can do this over several
queries in the session. If you do not use a session, a
multi-statement transaction needs to be completed in a single query.
Pricing
There are no additional costs for using sessions.
For projects that use on-demand pricing, queries against INFORMATION_SCHEMA
incur charges. For more information, see
INFORMATION_SCHEMA
pricing.
You are charged for temporary tables that you create in sessions. Storage
charges are based on how much data is stored in the tables. For information
about storage pricing, see Storage pricing.
Limitations
Every query in a session is run in the location where the session was
created.
A session is automatically terminated after 24 hours of inactivity.
A session is automatically terminated 7 days after its creation.
The maximum size of a session variable is 1 MB, and the maximum size of all
variables used in a session is 10 MB.
Concurrent queries aren't allowed within a session.
Roles and permissions
This section describes the
Identity and Access Management (IAM) permissions
and the IAM roles
that you need to perform actions with sessions.
Actions |
Required permissions |
Default roles |
Create a new session.
Work with an existing session that you created.
|
bigquery.jobs.create |
bigquery.user
bigquery.Jobuser
bigquery.admin
|
Terminate a session that you created.
|
bigquery.jobs.create |
bigquery.user
bigquery.Jobuser
bigquery.admin
|
Terminate a session another user created.
|
bigquery.jobs.create
bigquery.jobs.update
|
bigquery.admin
|
View a list of your sessions in a project.
This list includes the IDs for sessions you've created in a
project with
INFORMATION_SCHEMA.JOBS_BY_USER .
|
bigquery.jobs.list |
bigquery.user
bigquery.Jobuser
bigquery.admin
|
View all sessions for all users in a project.
This list includes the IDs for all sessions created in the
project with
INFORMATION_SCHEMA.JOBS .
|
bigquery.jobs.listAll |
bigquery.admin
|
View metadata for sessions created by the current user in the
current project with
INFORMATION_SCHEMA.SESSIONS_BY_USER .
|
bigquery.jobs.list |
bigquery.user
bigquery.Jobuser
bigquery.admin
|
View metadata for all sessions in the current project with
INFORMATION_SCHEMA.SESSIONS_BY_PROJECT .
|
bigquery.jobs.listAll |
bigquery.admin
|
What's next
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-29 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[[["\u003cp\u003eBigQuery sessions allow users to capture SQL activities, utilize temporary tables and functions, and maintain variables throughout the session.\u003c/p\u003e\n"],["\u003cp\u003eSessions provide the ability to view query history and track changes within a specific timeframe, up to 20 days after termination.\u003c/p\u003e\n"],["\u003cp\u003eMulti-statement transactions can be executed over multiple queries within a session, which is not possible without sessions.\u003c/p\u003e\n"],["\u003cp\u003eWhile there are no additional costs for using sessions, charges apply for queries against \u003ccode\u003eINFORMATION_SCHEMA\u003c/code\u003e and for temporary table storage.\u003c/p\u003e\n"],["\u003cp\u003eSessions have limitations, including a 24-hour automatic termination after inactivity, a 7-day termination after creation, and constraints on variable sizes, as well as no concurrent queries allowed in the same session.\u003c/p\u003e\n"]]],[],null,["# Introduction to sessions\n========================\n\nThis guide describes how to enable, create, and track changes in a\nBigQuery session. It is intended for users who are familiar with\n[BigQuery](/bigquery/docs) and\n[GoogleSQL](/bigquery/docs/reference/standard-sql/query-syntax).\n\nYou can capture your SQL activities in a BigQuery session.\nTemporary tables, temporary functions, and variables can be used throughout the session to\ninteractively build one or more queries. Multiple sessions can be active at the\nsame time and the history for each session is saved. You can view the history\nof a session for up to 20 days after the session is terminated.\n\nTypical uses for a session include the following:\n\n- **Maintain transient session data.** Define variables and temporary tables\n once and use them throughout the session.\n\n- **Look up query history by session.** If you want to keep track of a behavior\n that happened at a particular time during the session, you can view the\n history of changes that were made during the\n session.\n\n- **Create multi-statement transactions over multiple queries.** Within a\n session, you can begin a transaction, make changes, and view the temporary\n result before deciding to commit or rollback. You can do this over several\n queries in the session. If you do not use a session, a\n multi-statement transaction needs to be completed in a single query.\n\nPricing\n-------\n\n- There are no additional costs for using sessions.\n\n- For projects that use on-demand pricing, queries against `INFORMATION_SCHEMA`\n incur charges. For more information, see\n [`INFORMATION_SCHEMA` pricing](/bigquery/docs/information-schema-intro#pricing).\n\n- You are charged for temporary tables that you create in sessions. Storage\n charges are based on how much data is stored in the tables. For information\n about storage pricing, see [Storage pricing](/bigquery/pricing#storage).\n\nLimitations\n-----------\n\n- Every query in a session is run in the location where the session was\n created.\n\n- A session is automatically terminated after 24 hours of inactivity.\n\n- A session is automatically terminated 7 days after its creation.\n\n- The maximum size of a session variable is 1 MB, and the maximum size of all\n variables used in a session is 10 MB.\n\n- Concurrent queries aren't allowed within a session.\n\nRoles and permissions\n---------------------\n\nThis section describes the\n[Identity and Access Management (IAM) permissions](/bigquery/docs/access-control#bq-permissions)\nand the [IAM roles](/bigquery/docs/access-control#bigquery)\nthat you need to perform actions with sessions.\n\nWhat's next\n-----------\n\n- Learn more about how to [write queries in sessions](/bigquery/docs/sessions-write-queries).\n- Learn more about how to [work with sessions](/bigquery/docs/sessions), including how to create, use, terminate, and list your sessions."]]