Terminating sessions

This document describes how session termination works in BigQuery. It is intended for users who already have a general understanding of BigQuery sessions.

Before you complete these steps, ensure you have the necessary permissions to terminate a session.

Terminating a session

A session can be terminated manually or automatically. The history of a terminated session is available for 20 days after termination.

Auto-terminate a session

A session is terminated automatically after 24 hours of inactivity or after 7 days, whichever happens first.

Terminate the current session

You can terminate your current session with a SQL statement or in the Google Cloud console, if the session was created there.

Console

  1. In the Google Cloud console, go to the BigQuery page.

    Go to BigQuery

  2. Find the editor tab that contains your session and close it. The session is terminated.

SQL

Do the following to terminate your session:

  1. In the Google Cloud console, go to the BigQuery page.

    Go to BigQuery

  2. In the query editor, enter the following statement:

    CALL BQ.ABORT_SESSION();
    

  3. Click Run.

For more information about how to run queries, see Run an interactive query.

Terminate a session by ID

You can terminate a session using its ID. You do not need to be in the session to terminate it this way.

Get the session ID, and then run the following statement:

CALL BQ.ABORT_SESSION(SESSION_ID);

Replace SESSION_ID with the ID of the session to terminate.

What's next