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 | |
| Delete 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 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 |
Define 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 |
Last Article: DDL Syntax
Next Article: ALTER DATABASE
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.