[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe \u003ccode\u003eINFORMATION_SCHEMA.PARTITIONS\u003c/code\u003e view provides detailed information about each partition in a dataset, with each row representing a single partition.\u003c/p\u003e\n"],["\u003cp\u003eQuerying this view is limited to 1000 tables per query, and you may need to split queries and join results to access project-level partition data.\u003c/p\u003e\n"],["\u003cp\u003eSpecific IAM permissions like \u003ccode\u003ebigquery.tables.get\u003c/code\u003e, \u003ccode\u003ebigquery.tables.getData\u003c/code\u003e, and \u003ccode\u003ebigquery.tables.list\u003c/code\u003e are required to query the \u003ccode\u003eINFORMATION_SCHEMA.PARTITIONS\u003c/code\u003e view.\u003c/p\u003e\n"],["\u003cp\u003eThe view's schema includes columns such as \u003ccode\u003ePARTITION_ID\u003c/code\u003e, \u003ccode\u003eTOTAL_ROWS\u003c/code\u003e, \u003ccode\u003eTOTAL_LOGICAL_BYTES\u003c/code\u003e, \u003ccode\u003eLAST_MODIFIED_TIME\u003c/code\u003e, and \u003ccode\u003eSTORAGE_TIER\u003c/code\u003e, which describes the characteristics of the partition.\u003c/p\u003e\n"],["\u003cp\u003eThis view can be used to calculate logical bytes used by each storage tier, and to aggregate partition data at the table level, as demonstrated in the provided examples.\u003c/p\u003e\n"]]],[],null,["# PARTITIONS view\n===============\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThe `INFORMATION_SCHEMA.PARTITIONS` view contains one row for each partition.\n\nQuerying the `INFORMATION_SCHEMA.PARTITIONS` view is limited to 1000\ntables. To get the data about partitions at the project level, you can split the\nquery into multiple queries and then join the results. If you exceed the limit,\nyou can encounter an error similar to the following: \n\n```\nINFORMATION_SCHEMA.PARTITIONS query attempted to read too many tables. Please add more restrictive filters.\n```\n\nRequired permissions\n--------------------\n\nTo query the `INFORMATION_SCHEMA.PARTITIONS` view, you need the following\nIdentity and Access Management (IAM) permissions:\n\n- `bigquery.tables.get`\n- `bigquery.tables.list`\n\nEach of the following predefined IAM roles includes the preceding\npermissions:\n\n- `roles/bigquery.admin`\n- `roles/bigquery.dataEditor`\n- `roles/bigquery.dataViewer`\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.PARTITIONS` view, the query results\ntypically contain one row for each partition. The exception is when there is\na combination of long-term and active storage tier data in the\n[`__UNPARTITIONED__` partition](/bigquery/docs/querying-partitioned-tables#query_data_in_the_streaming_buffer). In that case,\nthe view returns two rows for the `__UNPARTITIONED__` partition, one for each\nstorage tier.\n\nThe `INFORMATION_SCHEMA.PARTITIONS` view has the following schema:\n\nScope and syntax\n----------------\n\nQueries against this view must include a dataset qualifier. For\nqueries with a dataset qualifier, you must have permissions for the dataset.\nFor more information\nsee [Syntax](/bigquery/docs/information-schema-intro#syntax).\nThe following table explains the region and resource scopes 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\"\u003eDATASET_ID\u003c/var\u003e: the ID of your dataset. For more information, see [Dataset qualifier](/bigquery/docs/information-schema-intro#dataset_qualifier).\n\n\u003cbr /\u003e\n\nExamples\n--------\n\n**Example 1**\n\nThe following example calculates the number of logical bytes used by each\nstorage tier in all of the tables in a dataset named `mydataset`: \n\n```googlesql\nSELECT\n storage_tier,\n SUM(total_logical_bytes) AS logical_bytes\nFROM\n `\u003cvar translate=\"no\"\u003emydataset\u003c/var\u003e.INFORMATION_SCHEMA.PARTITIONS`\nGROUP BY\n storage_tier;\n```\n| **Note:** `INFORMATION_SCHEMA` view names are case-sensitive.\n\nThe results look similar to the following: \n\n```\n+--------------+----------------+\n| storage_tier | logical_bytes |\n+--------------+----------------+\n| LONG_TERM | 1311495144879 |\n| ACTIVE | 66757629240 |\n+--------------+----------------+\n```\n\n**Example 2**\n\nThe following example creates a column that extracts the partition type from the\n`partition_id` field and aggregates partition information at the table level\nfor the public `bigquery-public-data.covid19_usafacts` dataset: \n\n```googlesql\nSELECT\n table_name,\n CASE\n WHEN regexp_contains(partition_id, '^[0-9]{4}$') THEN 'YEAR'\n WHEN regexp_contains(partition_id, '^[0-9]{6}$') THEN 'MONTH'\n WHEN regexp_contains(partition_id, '^[0-9]{8}$') THEN 'DAY'\n WHEN regexp_contains(partition_id, '^[0-9]{10}$') THEN 'HOUR'\n END AS partition_type,\n min(partition_id) AS earliest_partition,\n max(partition_id) AS latest_partition_id,\n COUNT(partition_id) AS partition_count,\n sum(total_logical_bytes) AS sum_total_logical_bytes,\n max(last_modified_time) AS max_last_updated_time\nFROM `bigquery-public-data.covid19_usafacts.INFORMATION_SCHEMA.PARTITIONS`\nGROUP BY 1, 2;\n```\n\nThe results look similar to the following: \n\n```\n+-----------------+----------------+--------------------+---------------------+-----------------+-------------------------+--------------------------------+\n| table_name | partition_type | earliest_partition | latest_partition_id | partition_count | sum_total_logical_bytes | max_last_updated_time |\n+--------------+-------------------+--------------------+---------------------+-----------------+-------------------------+--------------------------------+\n| confirmed_cases | DAY | 20221204 | 20221213 | 10 | 26847302 | 2022-12-13 00:09:25.604000 UTC |\n| deaths | DAY | 20221204 | 20221213 | 10 | 26847302 | 2022-12-13 00:09:24.709000 UTC |\n| summary | DAY | 20221204 | 20221213 | 10 | 241285338 | 2022-12-13 00:09:27.496000 UTC |\n+-----------------+----------------+--------------------+---------------------+-----------------+-------------------------+--------------------------------+\n```"]]