Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Tampilan SESSIONS_BY_PROJECT
Tampilan INFORMATION_SCHEMA.SESSIONS_BY_PROJECT berisi metadata real-time tentang semua sesi BigQuery dalam project saat ini.
Izin yang diperlukan
Untuk menjalankan kueri tampilan INFORMATION_SCHEMA.SESSIONS_BY_PROJECT, Anda memerlukan
izin Identity and Access Management (IAM) bigquery.jobs.listAll untuk
project tersebut.
Setiap peran IAM yang telah ditetapkan berikut menyertakan izin yang diperlukan:
Saat Anda membuat kueri tampilan INFORMATION_SCHEMA.SESSIONS_BY_*, hasil kueri akan berisi satu baris untuk setiap sesi BigQuery.
Tampilan INFORMATION_SCHEMA.SESSIONS_BY_* memiliki skema berikut:
Nama kolom
Jenis data
Nilai
creation_time
TIMESTAMP
(Kolom partisi) Waktu pembuatan sesi ini.
Partisi didasarkan pada waktu UTC stempel waktu ini.
expiration_time
TIMESTAMP
(Kolom partisi) Waktu habis masa berlaku sesi ini.
Partisi didasarkan pada waktu UTC stempel waktu ini.
is_active
BOOL
Apakah sesi masih aktif? TRUE jika ya, dan
FALSE jika tidak.
last_modified_time
TIMESTAMP
(Kolom partisi) Waktu saat sesi terakhir diubah.
Partisi didasarkan pada waktu UTC stempel waktu ini.
project_id
STRING
(Kolom pengelompokan) untuk project.
project_number
INTEGER
Nomor project.
session_id
STRING
ID sesi. Misalnya, bquxsession_1234.
user_email
STRING
(Kolom pengelompokan) Alamat email atau akun layanan pengguna yang menjalankan sesi.
Retensi data
Tampilan ini berisi sesi yang sedang berjalan dan histori sesi
yang selesai dalam 180 hari terakhir.
Cakupan dan sintaksis
Kueri terhadap tabel virtual ini harus menyertakan penentu region.
Jika Anda tidak menentukan penentu regional, metadata akan diambil dari semua region. Tabel berikut menjelaskan cakupan region untuk tabel virtual ini:
Misalnya, `myproject`.`region-us`.INFORMATION_SCHEMA.SESSIONS_BY_PROJECT.
Contoh berikut mencantumkan semua pengguna atau akun layanan yang membuat sesi untuk project tertentu dalam satu hari terakhir:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-17 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eINFORMATION_SCHEMA.SESSIONS_BY_PROJECT\u003c/code\u003e view provides real-time metadata for all BigQuery sessions within a project.\u003c/p\u003e\n"],["\u003cp\u003eAccessing this view requires the \u003ccode\u003ebigquery.jobs.listAll\u003c/code\u003e IAM permission, which is included in the Project Owner and BigQuery Admin roles.\u003c/p\u003e\n"],["\u003cp\u003eEach row in the query results corresponds to a single BigQuery session, containing information like creation time, expiration time, and user details.\u003c/p\u003e\n"],["\u003cp\u003eThis view retains data for currently running sessions and those completed within the past 180 days.\u003c/p\u003e\n"],["\u003cp\u003eQueries against this view must include a region qualifier, specifying the dataset region, and the query execution location must match the region of the view.\u003c/p\u003e\n"]]],[],null,["# SESSIONS_BY_PROJECT view\n========================\n\nThe `INFORMATION_SCHEMA.SESSIONS_BY_PROJECT` view contains real-time\nmetadata about all BigQuery sessions in the current project.\n\nRequired permissions\n--------------------\n\nTo query the `INFORMATION_SCHEMA.SESSIONS_BY_PROJECT` view, you need\nthe `bigquery.jobs.listAll` Identity and Access Management (IAM) permission for the project.\nEach of the following predefined IAM roles includes the\nrequired permission:\n\n- Project Owner\n- BigQuery Admin\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_PROJECT\n```\nFor example, ```myproject`.`region-us`.INFORMATION_SCHEMA.SESSIONS_BY_PROJECT``. The following example lists all users or service accounts that created sessions for a given project within the last day:\n\n\u003cbr /\u003e\n\n```googlesql\nSELECT\n DISTINCT(user_email) AS user\nFROM\n `region-us`.INFORMATION_SCHEMA.SESSIONS_BY_PROJECT\nWHERE\n is_active = true\n AND creation_time \u003e= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY);\n```\n| **Note:** `INFORMATION_SCHEMA` view names are case-sensitive.\n\nThe result is similar to the following: \n\n```\n+--------------+\n| user |\n+--------------+\n| abc@xyz.com |\n+--------------+\n| def@xyz.com |\n+--------------+\n```"]]