DDL Syntax Overview
Data definition language (DDL) is used to define or modify an object in a database, such as a table, an index, or a view.
GaussDB does not support DDL operations when the CN is incomplete. For example, if the primary node of the database is faulty, creating a database or a table will fail.
Defining a Role
A role is used to manage permissions. For database security, management and operation permissions can be granted to different roles. For details about related SQL statements, see Table 1.
Defining a User
A user is used to log in to a database. Different permissions can be granted to users for managing data accesses and operations of the users. For details about related SQL statements, see Table 2.
Defining a CMK
Client master keys (CMKs) are used to encrypt column encryption keys (CEKs) for the encrypted database feature. CMK definition includes creating and deleting a CMK. Table 3 lists the involved SQL statements.
Defining a CEK
CEKs are used to encrypt data for the encrypted database feature. You can create a CEK, change the client master key specified by a CEK, and delete a CEK. Table 3 lists the involved SQL statements.
Function |
SQL Statement |
---|---|
Creating a CEK |
|
Changing the CMK specified by a CEK |
|
Deleting a CEK |
Defining a Database
A database is the warehouse for organizing, storing, and managing data. Defining a database includes: creating a database, altering the database attributes, and dropping the database. Table 5 lists the involved SQL statements.
Defining a Schema
A schema is the set of a group of database objects and is used to control the access to the database objects. Table 6 lists the involved SQL statements.
Defining a Tablespace
A tablespace is used to manage data objects and corresponds to a catalog on a disk. Table 7 lists the involved SQL statements.
Defining a Table
A table is a special data structure in a database and is used to store data objects and relationship between data objects. Table 8 lists the involved SQL statements.
Defining a Partitioned Table
A partitioned table is a logical table used to improve query performance and does not store data (data is stored in ordinary tables). Table 9 lists the involved SQL statements.
Function |
SQL Statement |
---|---|
Creating a partitioned table |
|
Create a partition |
|
Altering partitioned table attributes |
|
Deleting a partition |
|
Dropping a partitioned table |
|
Creating a level-2 partitioned table |
|
Modifying partitions in a level-2 partitioned table |
Defining an Index
An index indicates the sequence of values in one or more columns in a database table. It is a data structure that improves the speed of data access to specific information in a database table. Table 10 lists the involved SQL statements.
Defining a Stored Procedure
A stored procedure is a set of SQL statements for achieving specific functions and is stored in the database after compiling. Users can specify a name and provide parameters (if necessary) to execute the stored procedure. Table 11 lists the involved SQL statements.
Defining a Function
In GaussDB, a function is similar to a stored procedure, which is a set of SQL statements. The function and stored procedure are used the same. Table 12 lists the involved SQL statements.
Defining a Package
A package consists of the package specification and package body. It is used to manage stored procedures and functions by class, which is similar to classes in languages such as Java and C++.
Function |
SQL Statement |
---|---|
Creating a package |
|
Deleting a package |
|
Altering a package attribute |
Defining a Cursor
To process SQL statements, the stored procedure thread assigns a memory segment to store context association. Cursors are handles or pointers to context regions. With a cursor, the stored procedure can control alterations in context areas. Table 14 lists the involved SQL statements.
Defining a Resource Pool
A resource pool is a system catalog used by the resource load management module to specify attributes related to resource management, such as Cgroups. Table 15 lists the involved SQL statements.
Defining an Aggregate Function
Function |
SQL Statement |
---|---|
Creating an aggregate function |
|
Modifying an aggregate function |
|
Deleting an aggregate function |
Defining Data Type Conversion
Function |
SQL Statement |
---|---|
Creating user-defined data type conversion |
|
Deleting user-defined data type conversion |
Defining a Plug-in Extension
This feature is for internal use only. You are advised not to use it.
Function |
SQL Statement |
---|---|
Creating an extension |
|
Modifying an extension |
|
Deleting an extension |
Defining an Operator
Function |
SQL Statement |
---|---|
Creating an operator |
|
Modifying an operator |
|
Deleting an operator |
|
Defining a new operator class |
Defining a Data Type
Function |
SQL Statement |
---|---|
Creating a data type |
|
Modifying a data type |
|
Deleting a data type |
Defining a Scheduled Task
Function |
SQL Statement |
---|---|
Creating a scheduled task |
|
Modifying a scheduled task |
|
Deleting a scheduled task |
Defining a Database Link
DATABASE LINK can be used to remotely operate a database object. Table 22 lists the involved SQL statements.
Defining an Audit Policy
Function |
SQL Statement |
---|---|
Creating a unified audit policy |
|
Modifying a unified audit policy |
|
Deleting an audit policy |
Defining a Directory
Function |
SQL Statement |
---|---|
Creating a directory |
|
Modifying attributes of a directory |
|
Deleting a specified directory |
Defining a Foreign Data Wrapper
Function |
SQL Statement |
---|---|
Creating a foreign data wrapper |
|
Modifying a foreign data wrapper |
|
Deleting a foreign data wrapper |
SQL Statements Related to the gs_global_config System Catalog
Function |
SQL Statement |
---|---|
Adding and modifying parameter values in the gs_global_config system catalog |
|
Deleting parameter values from the gs_global_config system catalog |
|
Inserting one or more weak passwords into the gs_global_config system catalog |
|
Clearing all weak passwords in the gs_global_config system catalog |
Defining a User Group
Function |
SQL Statement |
---|---|
Creating a user group |
|
Modifying attributes of a user group |
|
Deleting a user group |
Defining a Procedural Language
Function |
SQL Statement |
---|---|
Defining a new procedural language |
|
Modifying the definition of a procedural language |
|
Deleting a procedural language |
Defining a Masking Policy
Function |
SQL Statement |
---|---|
Creating a masking policy |
|
Modifying a masking policy |
|
Deleting a masking policy |
Defining a Materialized View
Function |
SQL Statement |
---|---|
Creating a complete-refresh materialized view |
|
Creating a fast-refresh materialized view |
|
Modifying multiple auxiliary attributes of an existing materialized view |
|
Forcibly deleting an existing materialized view from the database |
|
Refreshing a materialized view in complete refresh mode |
|
Refreshing a materialized view in fast refresh mode |
Defining a Resource Label
Function |
SQL Statement |
---|---|
Creating a resource label |
|
Modifying a resource label |
|
Deleting a resource label |
Defining a Row-Level Security Policy
Function |
SQL Statement |
---|---|
Creating a row-level security policy for a table |
|
Modifying an existing row-level security policy |
|
Deleting a row-level security policy from a table |
Defining a Sequence
Function |
SQL Statement |
---|---|
Adding a sequence to the current database |
|
Modifying parameters of an existing sequence |
|
Deleting a sequence from the current database |
Defining a Foreign Server
Function |
SQL Statement |
---|---|
Defining a new foreign server |
|
Adding, modifying, and deleting parameters of an existing server |
|
Deleting a data server |
Defining a Synonym Object
Function |
SQL Statement |
---|---|
Creating a synonym object |
|
Modifying the owner of a synonym object |
|
Deleting a specified synonym object |
Defining a Trigger
Function |
SQL Statement |
---|---|
Creating a trigger |
|
Renaming a trigger |
|
Deleting a trigger |
Defining a Mapping
Function |
SQL Statement |
---|---|
Defining a new mapping from a user to a foreign server |
|
Altering the definition of a user mapping |
|
Dropping a user mapping for a foreign server |
Defining a View
Function |
SQL Statement |
---|---|
Creating a view |
|
Modifying the auxiliary attributes of a view |
|
Forcibly deleting a view from the database |
Collecting Statistics
For details about how to collect statistics related to the contents of ordinary tables in the database, see ANALYZE | ANALYSE.
Creating an Encoding Conversion Task
For details about how to define a new conversion between two character set encodings, see CREATE CONVERSION.
Defining a Model
Function |
SQL Statement |
---|---|
Training a machine learning model and saving the model |
|
Deleting a model that has been trained and saved |
Defining a Rewriting Rule
Function |
SQL Statement |
---|---|
Defining a new rewriting rule |
|
Deleting a rewriting rule |
Defining a Security Label
Function |
SQL Statement |
---|---|
Creating a security label |
|
Applying, updating, or canceling a security label |
|
Deleting a security label |
Importing a Database/Table
Function |
SQL Statement |
---|---|
Preparation phase for importing a database |
|
Execution phase of importing a database |
|
Preparation phase for importing a table |
|
Execution phase of importing a table |
Clearing a Recycle Bin
GaussDB provides statements for clearing a recycle bin. For details, see PURGE.
Clustering a Table
GaussDB supports statements for clustering a table based on an index. For details, see CLUSTER.
Defining an Object Comment
GaussDB supports statements for defining or modifying an object comment. For details, see COMMENT.
Creating a Table Based on Query Results
GaussDB supports statements for creating a table based on query results and inserting queried data into the new table. For details, see SELECT INTO.
Restoring a Table to an Earlier State
GaussDB allows you to restore a table to an earlier state in the event of a manual operation or application error. For details, see TIMECAPSULE TABLE.
Clearing Table Data
GaussDB supports statements for quickly deleting all rows from a table. For details, see TRUNCATE.
Recycling Storage Space
GaussDB supports statements for recycling storage space occupied by deleted rows in a table or B-Tree index. For details, see VACUUM.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot