Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating a Text Audit Task

Updated on 2025-02-22 GMT+08:00

Scenarios

You want to check whether a SQL statement complies with specifications and affects performance.

Constraints

  • Only four types of syntax for nested statements can be audited. For details, see Table 1.
  • Recommended indexes are available only for GaussDB.
  • When WITH AS is used, only SELECT subqueries are supported.
  • The table name and table alias must be different. The aliases of different tables must be different.
  • Tables in the audit view cannot be audited.
  • Database system tables and system views cannot be audited.
  • MySQL statements containing number signs (#) cannot be audited.
    Table 1 Supported nested statements

    No.

    SQL Statement

    1

    select id, (select subquery) as name from table;

    2

    select id from table where id in (select subquery);

    3

    select * from table1, (select ...);

    4

    with e as (select ...) select * from e;

Rule Constraints

  • In all UPDATE and DELETE rules, multiple tables cannot be updated and deleted at a time.
  • Multi-table UPDATE and DELETE operations are audited based on the rule Do not use a single UPDATE or DELETE statement to update or delete multiple tables.
  • For rules In the PL/pgSQL, use uppercase for keywords and lowercase for non-keywords and In SQL statements, use uppercase for keywords and lowercase for non-keywords, you are not advised using object names as non-reserved keywords, or the audit may be inaccurate. For example, in SELECT ID FROM name, name is a non-reserved keyword.
  • After the database system parameter enable_gpi_auto_update is modified, the rule Global indexes must be updated when partitions are swapped, merged, separated, cleared, or deleted in a partitioned table may not take effect. To clear sessions in the database, you can log in to the database.
    CLEAN CONNECTION TO ALL FORCE FOR DATABASE db_name;
  • When object names are used as filters for querying system views, use lowercase object names. For details about supported system views, see Table 2.
  • Exercise caution when deleting database objects and data. For supported SQL Syntax, see Table 3.
    Table 2 View audit

    View Name

    Schema

    Object Name Column

    adm_arguments

    pg_catalog, sys

    owner, object_name, package_name, argument_name

    adm_audit_object

    pg_catalog, sys

    username, owner, obj_name, action_name

    adm_audit_session

    pg_catalog, sys

    username, action_name

    adm_audit_statement

    pg_catalog, sys

    username, obj_name, action_name

    adm_col_comments

    pg_catalog, sys

    owner, table_name, column_name, schema

    adm_col_privs

    pg_catalog, sys

    grantor, owner, grantee, table_schema, table_name, column_name, privilege

    adm_coll_types

    pg_catalog, sys

    owner, type_name, elem_type_mod, elem_type_owner, elem_type_name

    adm_constraints

    pg_catalog, sys

    owner, constraint_name, table_name, index_owner, index_name

    adm_indexes

    pg_catalog, sys

    owner, index_name, table_name, table_owner, tablespace_name

    adm_ind_columns

    pg_catalog, sys

    index_owner, index_name, table_name, table_owner, column_name

    adm_objects

    pg_catalog, sys

    owner, object_name, subobject_name

    adm_procedures

    pg_catalog, sys

    owner, object_name, procedure_name, impltypeowner, impltypename

    adm_role_privs

    pg_catalog, sys

    grantee, granted_role

    adm_tab_col_statistics

    pg_catalog, sys

    owner, table_name, column_name, schema

    adm_roles

    pg_catalog, sys

    role

    adm_source

    pg_catalog, sys

    owner, name

    adm_sys_privs

    pg_catalog, sys

    grantee, privilege

    adm_tab_cols

    pg_catalog, sys

    owner, table_name, column_name, data_type_owner, schema, qualified_col_name

    adm_tab_privs

    pg_catalog, sys

    grantee, owner, table_name, grantor, privilege

    adm_tables

    pg_catalog, sys

    owner, table_name, tablespace_name

    adm_tab_columns

    pg_catalog, sys

    owner, table_name, column_name, data_type_owner, schema

    adm_tab_comments

    pg_catalog, sys

    owner, table_name, column_name, schema

    adm_tab_statistics

    pg_catalog, sys

    owner, table_name

    adm_triggers

    pg_catalog, sys

    owner, trigger_name, table_owner, table_name

    adm_type_attrs

    pg_catalog, sys

    type_name, attr_name, attr_type_name, character_set_name

    adm_types

    pg_catalog, sys

    owner, type_name

    adm_users

    pg_catalog, sys

    username, default_tablespace, temporary_tablespace, default_collation

    adm_views

    pg_catalog, sys

    owner, view_name

    db_all_tables

    pg_catalog, sys

    owner, table_name, tablespace_name

    db_arguments

    pg_catalog, sys

    owner, object_name, package_name, argument_name

    db_col_comments

    pg_catalog, sys

    owner, table_name, column_name, schema

    db_col_privs

    pg_catalog, sys

    grantor, owner, grantee, table_schema, table_name, column_name, privilege

    db_coll_types

    pg_catalog, sys

    owner, type_name, elem_type_mod, elem_type_owner, elem_type_name

    db_constraints

    pg_catalog, sys

    owner, constraint_name, table_name, index_owner, index_name

    db_indexes

    pg_catalog, sys

    owner, index_name, table_name, table_owner, tablespace_name

    db_ind_columns

    pg_catalog, sys

    index_owner, index_name, table_name, table_owner, column_name

    db_objects

    pg_catalog, sys

    owner, object_name, subobject_name

    db_procedures

    pg_catalog, sys

    owner, object_name

    db_tab_col_statistics

    pg_catalog, sys

    owner, table_name, column_name, schema

    db_source

    pg_catalog, sys

    owner, name

    db_tab_columns

    pg_catalog, sys

    owner, table_name, column_name, data_type_owner, schema

    db_tab_comments

    pg_catalog, sys

    owner, table_name, schema

    db_tables

    pg_catalog, sys

    owner, table_name, tablespace_name

    db_triggers

    pg_catalog, sys

    trigger_name, table_owner, table_name

    db_types

    pg_catalog, sys

    owner, type_name

    db_users

    pg_catalog, sys

    username

    db_views

    pg_catalog, sys

    owner, view_name

    dict

    pg_catalog, sys

    table_name

    dictionary

    pg_catalog, sys

    table_name

    my_col_comments

    pg_catalog, sys

    owner, table_name, column_name, schema

    my_col_privs

    pg_catalog, sys

    grantor, owner, grantee, table_schema, table_name, column_name, privilege

    my_coll_types

    pg_catalog, sys

    owner, type_name, elem_type_mod, elem_type_owner, elem_type_name

    my_constraints

    pg_catalog, sys

    owner, constraint_name, table_name, index_owner, index_name

    my_indexes

    pg_catalog, sys

    owner, index_name, table_name, table_owner, tablespace_name

    my_ind_columns

    pg_catalog, sys

    index_owner, index_name, table_name, table_owner, column_name

    my_objects

    pg_catalog, sys

    object_name, subobject_name

    my_procedures

    pg_catalog, sys

    owner, object_name, procedure_name, impltypeowner, impltypename

    my_role_privs

    pg_catalog, sys

    grantee, granted_role

    my_tab_col_statistics

    pg_catalog, sys

    table_name, column_name, schema

    my_source

    pg_catalog, sys

    owner, name

    my_tab_columns

    pg_catalog, sys

    owner, table_name, column_name, data_type_owner, schema

    my_tab_comments

    pg_catalog, sys

    owner, table_name, column_name, schema

    my_tab_statistics

    pg_catalog, sys

    table_name

    my_tables

    pg_catalog, sys

    owner, table_name, tablespace_name

    my_triggers

    pg_catalog, sys

    owner, trigger_name, table_owner, table_name

    my_type_attrs

    pg_catalog, sys

    type_name, attr_name, attr_type_name, character_set_name

    my_types

    pg_catalog, sys

    type_name

    my_views

    pg_catalog, sys

    owner, view_name

    pg_indexes

    pg_catalog, sys

    schemaname, tablename, indexname, tablespace

    pg_roles

    pg_catalog, sys

    rolename

    pg_tables

    pg_catalog, sys

    schemaname, tablename, tableowner, tablespace, tablecreator

    pg_user

    pg_catalog, sys

    username, nodegroup

    pg_views

    pg_catalog, sys

    schemaname, viewname, viewowner

    column_privileges

    information_schema, sys

    grantor, grantee, table_catalog, table_schema, table_name, column_name

    columns

    information_schema, sys

    table_catalog, table_schema, table_name, column_name

    constraint_column_usage

    information_schema, sys

    table_catalog, table_schema, table_name, column_name, constraint_catalog, constraint_schema, constraint_name

    constraint_table_usage

    information_schema, sys

    table_catalog, table_schema, table_name, constraint_catalog, constraint_schema, constraint_name

    enabled_roles

    information_schema, sys

    role_name

    schemata

    information_schema, sys

    catalog_name, schema_name, schema_owner, default_character_set_catalog, default_character_set_schema, default_character_set_name

    table_constraints

    information_schema, sys

    constraint_catalog, constraint_schema, constraint_name, table_catalog, table_schema, table_name

    table_privileges

    information_schema, sys

    grantor, grantee, table_catalog, table_schema, table_name

    tables

    information_schema, sys

    table_catalog, table_schema, table_name, self_referencing_column_name, user_defined_type_catalog, user_defined_type_schema, user_defined_type_name

    triggers

    information_schema, sys

    trigger_catalog, trigger_schema, trigger_name, event_object_catalog, event_object_schema, event_object_table, action_reference_old_table, action_reference_new_table

    usage_privileges

    information_schema, sys

    grantor, grantee, object_catalog, object_schema, object_name

    views

    information_schema, sys

    table_catalog, table_schema, table_name

    Table 3 SQL syntax that can be audited

    DDL Type

    SQL syntax

    DROP

    DROP TABLE, DROP TABLESPACE,

    DROP AGGREGATE, DROP AUDIT POLICY,

    DROP CAST, DROP DATABASE,

    DROP DATA SOURCE, DROP DIRECTORY,

    DROP EVENT, DROP FOREIGN TABLE,

    DROP GLOBAL CONFIGURATION, DROP GROUP,

    DROP MASKING POLICY, DROP MATERIALIZED VIEW,

    DROP MODEL, DROP OPERATOR,

    DROP OWNED, DROP PACKAGE,

    DROP PACKAGE BODY, DROP PROCEDURE,

    DROP RESOURCE LABEL, DROP RESOURCE POOL,

    DROP ROLE, DROP ROW LEVEL SECURITY POLICY,

    DROP RULE, DROP PUBLICATION,

    DROP SCHEMA, DROP SEQUENCE, DROP FUNCTION,

    DROP SERVER, DROP SUBSCRIPTION,

    DROP SYNONYM, DROP TEXT SEARCH CONFIGURATION,

    DROP TEXT SEARCH DICTIONARY, DROP TRIGGER,

    DROP TYPE, DROP USER, DROP USER MAPPING,

    DROP VIEW, DROP WEAK PASSWORD DICTIONARY

    ALTER

    ALTER DROP PARTITION, ALTER TRUNCATE PARTITION,

    ALTER DROP COLUMN, ALTER DROP CONSTRAINT,

    ALTER DROP FOREIGN TABLE, ALTER DROP AUDIT POLICY,

    ALTER DROP MASKING POLICY, ALTER DROP SERVER,

    ALTER DROP TEXT SEARCH CONFIGURATION,

    ALTER DROP USER MAPPING, ALTER DROP DATA SOURCE

    TRUNCATE

    TRUNCATE

Procedure

  1. Log in to the UGO console.
  2. In the navigation pane, choose SQL Audit > Statement Audit. The SQL Text page is displayed by default.
  3. Configure parameters as needed and view that the Submit button is highlighted.

    Figure 1 Audited Text
    Table 4 Parameter description

    Parameter

    Example Value

    Description

    Database Type

    GaussDB

    Select a database type. Currently, only GaussDB, MySQL, and PostgreSQL are supported.

    Data Source

    app_db_01

    Select a data source. Currently, only GaussDB, MySQL, and PostgreSQL are supported.

    This parameter is optional. If no data source is provided, the audit rules that depend on the data source are skipped by default.

    Schema

    demo_schema_01

    Select a schema. This parameter is optional and only available for GaussDB and PostgreSQL databases.

    • If the SQL statement contains a schema name, use the schema in the SQL statement.
    • If the SQL statement does not contain a schema name, the selected schema is used.
    • If the SQL statement does not contain a schema name and no schema is selected, use the public schema.

    Rule Template

    baseline_template_01

    Select a template based on the selected database type.

    You can set the template information by referring to Adding a Rule Template.

    SQL Statement

    select * from table;

    Enter the SQL statement to be audited.

    • Text audit is supported only for a single statement. If there are multiple statements, only the first statement is audited.
    • If a SQL object name is in uppercase and is not enclosed in double quotation marks, the system automatically converts the name to lowercase and then queries the corresponding table structure in the database.

  4. Click Submit. The View Details dialog box is displayed, and a corresponding record is generated.

    Figure 2 Viewing details

    Click the template name next to Rule Template to view template information.

    If the statement fails to be audited, the cause is displayed.

    Failure causes (examples):

    • line:1, position:14, token:table indicates the SQL statement contains table.
    • line:1, position:3, token:<EOF> indicates the entered SQL statement is incomplete.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback