-- Returns metadata for views in a single dataset.SELECT*FROMmyDataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS;-- Returns metadata for all views in a region.SELECT*FROMregion-us.INFORMATION_SCHEMA.MATERIALIZED_VIEWS;
[[["易于理解","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-08-28。"],[[["\u003cp\u003eThe \u003ccode\u003eINFORMATION_SCHEMA.MATERIALIZED_VIEWS\u003c/code\u003e view provides status information about materialized views, including last refresh time, refresh watermark, and last refresh status.\u003c/p\u003e\n"],["\u003cp\u003eTo query the \u003ccode\u003eINFORMATION_SCHEMA.MATERIALIZED_VIEWS\u003c/code\u003e view, you need the \u003ccode\u003eBigQuery Metadata Viewer\u003c/code\u003e role or specific permissions like \u003ccode\u003ebigquery.tables.get\u003c/code\u003e and \u003ccode\u003ebigquery.tables.list\u003c/code\u003e on your project or dataset.\u003c/p\u003e\n"],["\u003cp\u003eQueries against this view require a dataset or region qualifier, and you must have the appropriate permissions for either the dataset or the project.\u003c/p\u003e\n"],["\u003cp\u003eThe view's schema includes columns like \u003ccode\u003eTABLE_CATALOG\u003c/code\u003e, \u003ccode\u003eTABLE_SCHEMA\u003c/code\u003e, \u003ccode\u003eTABLE_NAME\u003c/code\u003e, \u003ccode\u003eLAST_REFRESH_TIME\u003c/code\u003e, \u003ccode\u003eREFRESH_WATERMARK\u003c/code\u003e, and \u003ccode\u003eLAST_REFRESH_STATUS\u003c/code\u003e, offering insights into materialized view metadata.\u003c/p\u003e\n"],["\u003cp\u003eThe materialized view is under a pre-GA offering, meaning that the product or feature is available "as is" and might have limited support.\u003c/p\u003e\n"]]],[],null,["# MATERIALIZED_VIEWS 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.MATERIALIZED_VIEWS` view contains status about materialized views.\n\nRequired permissions\n--------------------\n\n\nTo get the permissions that\nyou need to query the `INFORMATION_SCHEMA.MATERIALIZED_VIEWS` view,\n\nask your administrator to grant you the\n\n\n[BigQuery Metadata Viewer](/iam/docs/roles-permissions/bigquery#bigquery.metadataViewer) (`roles/bigquery.metadataViewer`)\nIAM role on your project or dataset.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nThis predefined role contains\n\nthe permissions required to query the `INFORMATION_SCHEMA.MATERIALIZED_VIEWS` view. To see the exact permissions that are\nrequired, expand the **Required permissions** section:\n\n\n#### Required permissions\n\nThe following permissions are required to query the `INFORMATION_SCHEMA.MATERIALIZED_VIEWS` view:\n\n- ` bigquery.tables.get `\n- ` bigquery.tables.list`\n\n\nYou might also be able to get\nthese permissions\nwith [custom roles](/iam/docs/creating-custom-roles) or\nother [predefined roles](/iam/docs/roles-overview#predefined).\nFor more information about BigQuery permissions, see [Access control with IAM](/bigquery/docs/access-control).\n\n\u003cbr /\u003e\n\nSchema\n------\n\nWhen you query the `INFORMATION_SCHEMA.MATERIALIZED_VIEWS` view, the query results contain\none row for each materialized view in a dataset.\n\nThe `INFORMATION_SCHEMA.MATERIALIZED_VIEWS` view has the following schema:\n\nScope and syntax\n----------------\n\nQueries against this view must include a dataset or a region qualifier. For\nqueries with a dataset qualifier, you must have permissions for the dataset.\nFor queries with a region qualifier, you must have permissions for the project.\nFor more\ninformation, see [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\"\u003eREGION\u003c/var\u003e: any [dataset region name](/bigquery/docs/locations). For example, ```region-us```.\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\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\nFor example: \n\n -- Returns metadata for views in a single dataset.\n SELECT * FROM myDataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS;\n\n -- Returns metadata for all views in a region.\n SELECT * FROM region-us.INFORMATION_SCHEMA.MATERIALIZED_VIEWS;\n\nExamples\n--------\n\n##### Example 1:\n\nThe following example retrieves all the unhealthy materialized views from the\n`INFORMATION_SCHEMA.MATERIALIZED_VIEWS` view. It returns the materialized views\nwith non `NULL` `last_refresh_status` values in `mydataset` in your default\nproject --- `myproject`.\n\nTo run the query against a project other than your default project, add the\nproject ID to the dataset in the following format:\n```````\u003cvar translate=\"no\"\u003eproject_id\u003c/var\u003e````.```\u003cvar translate=\"no\"\u003edataset\u003c/var\u003e```.INFORMATION_SCHEMA.MATERIALIZED_VIEWS```;\nfor example, ```myproject`.mydataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS``. \n\n```googlesql\nSELECT\n table_name, last_refresh_status\nFROM\n mydataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS\nWHERE\n last_refresh_status IS NOT NULL;\n```\n| **Note:** `INFORMATION_SCHEMA` view names are case-sensitive.\n\nThe result is similar to the following:\n\n\u003cbr /\u003e\n\n```\n +---------------+---------------------------------------------------------------------+\n | table_name | last_refresh_status |\n +---------------------------------------------------------------------+---------------+\n | myview | {\"reason\":\"invalidQuery\",\"location\":\"query\",\"message\":\"...\"} |\n +---------------------------------------------------------------------+---------------+\n \n```\n\n\u003cbr /\u003e\n\n##### Example 2:\n\nThe following example retrieves the `last_refresh_time` and `refresh_watermark`\nof materialized view `myview` in `mydataset` in your default project ---\n`myproject`. The result shows when the materialized was last refreshed and up to\nwhen data of base tables are collected into the materialized view cache.\n\nTo run the query against a project other than your default project, add the\nproject ID to the dataset in the following format:\n```````\u003cvar translate=\"no\"\u003eproject_id\u003c/var\u003e````.```\u003cvar translate=\"no\"\u003edataset\u003c/var\u003e```.INFORMATION_SCHEMA.MATERIALIZED_VIEWS```;\nfor example, ```myproject`.mydataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS``. \n\n```googlesql\nSELECT\n table_name, last_refresh_time, refresh_watermark\nFROM\n mydataset.INFORMATION_SCHEMA.MATERIALIZED_VIEWS\nWHERE\n table_name = 'myview';\n```\n| **Note:** `INFORMATION_SCHEMA` view names are case-sensitive.\n\nThe result is similar to the following:\n\n\u003cbr /\u003e\n\n```\n +---------------+------------------------------------------------+\n | table_name | last_refresh_time | refresh_watermark |\n +---------------+------------------------------------------------+\n | myview | 2023-02-22 19:37:17 | 2023-03-08 16:52:57 |\n +---------------+------------------------------------------------+\n \n```\n\n\u003cbr /\u003e\n\n| **Note:** If there have been no recent changes to the base tables, BigQuery periodically increases the `refresh_watermark` to indicate that the materialized view is up-to-date without actually refreshing it. As a result, the `last_refresh_time` can be earlier than the `refresh_watermark`."]]