Introduction to metadata and management of GaussDB database

Table of contents

I. Introduction

2. Introduction to Metadata

1. Metadata definition

2. Metadata classification

3. Database metadata management

3. Metadata management of GaussDB database

1. Metadata management of GaussDB database

2. Manage (collect) metadata through "SQL + system table/system view/system function"

1) Obtain information such as tables, views, and table fields

2) Get timed task information

3) Get index information

4) Obtain information such as stored procedures, functions, triggers, etc.

Four. Summary

I. Introduction

GaussDB is a distributed relational database, and metadata (tables, columns, views, indexes, stored procedures, etc.) is an important part of it. Metadata refers to data describing data, including data definition, structure, attributes, relationships and other information. This article focuses on the GaussDB physical database, and briefly introduces the relevant content in combination with the concept of metadata.

2. Introduction to Metadata

1. Metadata definition

According to the traditional definition, metadata (Metadata) is data that describes data. Metadata mainly records the definition of the model in the database application system, the mapping relationship between each level, the data status of the monitoring database application system and the task running status of ETL, etc. In database application systems, metadata can help database administrators and developers find the data they care about very conveniently, and use it to guide them in data management and development work, improving work efficiency.

2. Metadata classification

Metadata can be classified according to different dimensions, and can be divided into two categories according to different purposes: technical metadata (Technical Metadata) and business metadata (Business Metadata).

  • Technical metadata is the data that stores the technical details of the database application system, and is used to develop and manage the data used by the database application system. Technical metadata is technical assets, showing the number of databases, data tables, data volumes and their details.
  • Business metadata describes the data in the database application system from a business point of view. It provides a semantic layer between the user and the actual system, so that business personnel who do not understand computer technology can also "understand" the data in the database application system. data. Business metadata includes business assets and index assets. Business assets display the number and details of business objects, logical entities, and business attributes. Index assets display business indicators and their details.

3. Database metadata management

Metadata management is the description information of the whole data life cycle such as data collection, storage, processing and presentation, and helps users understand data relationships and related attributes. Metadata of a database refers to information about database objects (such as tables, columns, indexes, views, stored procedures, etc.) that describe the structure and properties of these objects. And the ultimate goal is to serve the efficient implementation (development, management, maintenance, etc.) of the database application system.

3. Metadata management of GaussDB database

1. Metadata management of GaussDB database

By logging into the "Data Management Service (DAS)" tool provided by GaussDB and entering the main page of "Library Management (Schema List/Object List/Metadata Collection)", basic management of related metadata can be performed (as shown in the figure below).

List of GaussDB database objects:

  GaussDB database metadata collection ( built-in function of DAS tool):

Tip: The object list data comes from real-time query (up to 10,000 items can be displayed), which consumes a certain amount of performance on the database. It is recommended to enable automatic metadata collection.

2. Manage (collect) metadata through "SQL + system table/system view/system function"

1 ) Obtain information such as tables, views, and table fields

(1) PG_GET_TABLEDEF(tablename) system information function to obtain table definition information.

SELECT * FROM PG_GET_TABLEDEF(‘test_1’);

 Return type: text. Explanation: pg_get_tabledef reconstructs the CREATE statement of the table definition, including the table definition itself, index information, and comments information. For the group, schema, tablespace, server and other information that the table object depends on.

(2) The ADM_TABLES view stores information about all tables under the database. Main fields: owner of the table, table name, name of the table space where the table is stored, estimated number of rows of the table, whether it is a temporary table, etc.

SELECT * FROM ADM_TABLES;

 (3) The DB_ALL_TABLES view stores the tables or views that the current user can access. Key fields: owner of the table or view, name of the table or view, tablespace in which the table or view resides.

SELECT * FROM DB_ALL_TABLES;

 (4) The DB_TABLES view stores all tables accessible to the current user. Main fields: the owner of the table, the name of the table, the name of the table space where the table is stored, the estimated number of rows of the table, whether it is a temporary table, etc.

SELECT * FROM DB_TABLES;

(5) The ADM_TAB_COLUMNS view stores field information about tables and views. There is one row in ADM_TAB_COLUMNS for each field in each table or view in the database. Main fields: owner of the table, name of the table, column name, data type of the column, byte length of the column, etc.

SELECT * FROM  ADM_TAB_COLUMNS;

 (6) The DB_TAB_COLUMNS view stores the description information of the columns of tables and views accessible to the current user. Main fields: owner of the table, name of the table, column name, data type of the column, byte length of the column, etc.

SELECT * FROM  DB_TAB_COLUMNS;

2 ) Obtain timing task information

The MY_JOBS system view gets its definition information. Main fields: job creator, job executor, database name corresponding to the job, start execution time, end time, running status, etc.

-- Get timed task information

SELECT * FROM MY_JOBS;

3 ) Get index information

The PG_INDEXES system view obtains the index information in the table

-- Obtain the corresponding index information according to the table name

SELECT schemaname

      ,tablename

      ,indexname

      ,tablespace

      ,indexdef

FROM PG_INDEXES

WHERE TABLENAME = 'sell_info_full'

AND INDEXNAME IS NOT NULL;

4 ) Obtain information such as stored procedures, functions, triggers, etc.

The DB_SOURCE view stores the definition information of stored procedures, functions, and triggers accessible to the current user. This view exists under both PG_CATALOG and SYS schema. Main fields: the owner of the object, the name of the object, the type of the object (function, procedure, trigger), the text source of the stored object, etc.

SELECT * FROM DB_SOURCE;

The acquisition/collection of GaussDB database metadata is mainly through system tables, views, functions, etc. The metadata includes not only TABLES, VIEWS, COLUMNS, SOURCE, JOB, but also USERS, COMMENTS, etc. Specifically, collection and management can be carried out according to actual business needs.

Four. Summary

Metadata management From a technical point of view , metadata manages technical metadata such as an enterprise's data source system, data platform, data warehouse, data model, database, table, field, and data relationship between fields. From a business perspective , metadata manages business metadata such as an enterprise's business glossary, business rules, quality rules, security policies, table processing policies, and table lifecycle information. From the perspective of application systems , metadata management provides complete processing and full-link tracking for data, which facilitates data traceability and auditing, which is increasingly important for the compliant use of data. Through data lineage analysis, trace the root cause of data quality problems and other errors, and perform impact analysis on changed metadata, etc.

Metadata management of GaussDB database is one of the cores of database system management. It can help users better manage and maintain the database, improve data security and reliability, and reduce the risk of data loss and damage. At the same time, metadata management can also help users better understand and use the database and improve work efficiency.

--Finish

Guess you like

Origin blog.csdn.net/GaussDB/article/details/132098621