Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Introdução às sessões
Este guia descreve como ativar, criar e rastrear alterações em uma sessão do BigQuery. Ele é destinado a usuários familiarizados com o
BigQuery e o
GoogleSQL.
É possível capturar suas atividades de SQL em uma sessão do BigQuery.
Variáveis, tabelas e funções temporárias podem ser usadas durante a sessão para
criar de maneira interativa uma ou mais consultas. Várias sessões podem estar ativas ao mesmo tempo e o histórico de cada sessão é salvo. É possível ver o histórico de uma sessão por até 20 dias após o encerramento dela.
Os usos típicos de uma sessão incluem o seguinte:
Mantenha dados temporários de sessão. Defina variáveis e tabelas temporárias uma vez e use-as durante a sessão.
Pesquisar o histórico de consultas por sessão. Se você quiser acompanhar um comportamento que aconteceu em um determinado momento durante a sessão, poderá ver o histórico de alterações feitas durante a sessão.
Crie transações com várias instruções em várias consultas. Em uma sessão, é possível iniciar uma transação, fazer alterações e ver o resultado temporário antes de confirmar ou reverter. É possível fazer isso em várias consultas na sessão. Se você não usar uma sessão, uma transação com várias instruções precisará ser concluída em uma única consulta.
Preços
Não há custos adicionais para usar sessões.
Para projetos que usam sistema de preços sob demanda, as consultas nas cobranças INFORMATION_SCHEMA são realizadas. Para saber mais informações, consulte INFORMATION_SCHEMAPreços.
Você será cobrado por tabelas temporárias que criar em sessões. As cobranças de armazenamento são baseadas na quantidade de dados armazenados nas tabelas. Para informações sobre preços de armazenamento, consulte esta página.
Limitações
Cada consulta em uma sessão é executada no local em que a sessão foi criada.
Uma sessão é encerrada automaticamente após 24 horas de inatividade.
Uma sessão é encerrada automaticamente sete dias após a criação.
O tamanho máximo de uma variável é 1 MB, e o tamanho máximo de todas
as variáveis usadas em um script é de 10 MB.
Não são permitidas consultas simultâneas na mesma sessão.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-25 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."]]