DDL Syntax Overview
Data definition language (DDL) is used to define or modify an object in a database, such as a table, index, or view.
GaussDB(DWS) does not support DDL if its CN is unavailable. For example, if a CN in the cluster is faulty, creating a database or table will fail.
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. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a database |
|
Alter database attributes |
|
Delete a database |
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. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a schema |
|
Alter schema attributes |
|
Delete a schema |
Defining a Table
A table is a special data structure in a database and is used to store data objects and the relationship between data objects. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a table |
|
Alter table attributes |
|
Alter a table name |
|
Delete a table |
|
Delete all the data from a table |
Defining a Partitioned Table
A partitioned table is a special data structure in a database and is used to store data objects and the relationship between data objects. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a partitioned table |
|
Create a partition |
|
Alter partitioned table attributes |
|
Delete a partition |
|
Delete a partitioned table |
Defining an Index
An index indicates the sequence of values in one or more columns in the database table. The database index is a data structure that improves the speed of data access to specific information in a database table. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create an index |
|
Alter index attributes |
|
Delete an index |
|
Rebuild an index |
Defining a Role
A role is used to manage rights. For database security, all management and operation rights can be assigned to different roles. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a role |
|
Alter role attributes |
|
Delete a role |
Defining a User
A user is used to log in to a database. Different rights can be assigned to users for managing data accesses and operations of users. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a user |
|
Alter user attributes |
|
Delete a user |
Defining a Redaction Policy
Data redaction is to protect sensitive data by masking or changing data. You can create a data redaction policy for a specific table object and specify the effective scope of the policy. You can also add, modify, and delete redaction columns. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a data redaction policy |
|
Modify a data redaction policy applied to a specified table |
|
Delete a data redaction policy applied to a specified table |
Defining Row-Level Access Control
Row-level access control policies control the visibility of rows in database tables. In this way, the same SQL query may return different results for different users. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a row-level access control policy |
|
Modify an existing row-level access control policy |
|
Delete a row-level access control policy from a table |
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. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a stored procedure |
|
Delete a stored procedure |
Defining a Function
In GaussDB(DWS), a function is similar to a stored procedure, which is a set of SQL statements. The function and stored procedure are used the same. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a function |
|
Alter function attributes |
|
Delete a function |
Defining a View
A view is a virtual table exported from one or several basic tables. The view is used to control data accesses for users. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a view |
|
Delete a view |
Defining a Cursor
To process SQL statements, the stored procedure process 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.
Altering or Ending a Session
A session is a connection established between the user and the database. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Alter a session |
|
End a session |
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. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a resource pool |
|
Change resource attributes |
|
Delete a resource pool |
Defining Synonyms
A synonym is a special database object compatible with Oracle. It is used to store the mapping between a database object and another. Currently, only synonyms can be used to associate the following database objects: tables, views, functions, and stored procedures. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Creating a synonym |
|
Modifying a synonym |
|
Deleting a synonym |
Defining Text Search Configuration
A text search configuration specifies a text search parser that can divide a string into tokens, plus dictionaries that can be used to determine which tokens are of interest for searching. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a text search configuration |
|
Modify a text search configuration |
|
Delete a text search configuration |
Defining a Full-text Retrieval Dictionary
A dictionary is used to identify and process specific words during full-text retrieval. Dictionaries are created by using predefined templates (defined in the PG_TS_TEMPLATE system catalog). Five types of dictionaries can be created, Simple, Ispell, Synonym, Thesaurus, and Snowball. Each type of dictionaries is used to handle different tasks. The following table lists the related SQL statements.
Function |
SQL Statement |
---|---|
Create a full-text retrieval dictionary |
|
Modify a full-text retrieval dictionary |
|
Delete a full-text retrieval dictionary |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.