CREATE RESOURCE LABEL
Description
Creates a resource label.
Precautions
Only users with the POLADMIN or SYSADMIN permission, or the initial user can perform this operation.
Syntax
1
|
CREATE RESOURCE LABEL [IF NOT EXISTS] label_name ADD label_item_list[, ...]*; |
- label_item_list
1
resource_type(resource_path[, ...]*)
- resource_type
TABLE | COLUMN | SCHEMA | VIEW | FUNCTION
Parameters
- IF NOT EXISTS
If a resource label with the same name already exists, no error is generated. Instead, a message is displayed, indicating that the resource label already exists.
- label_name
Specifies the resource label name, which must be unique.
Value range: a string that complies with the Identifier Naming Conventions.
- resource_type
Specifies the type of database resources to be labeled.
- resource_path
Specifies the path of database resources.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
-- Create table tb_for_label. openGauss=# CREATE TABLE tb_for_label(col1 text, col2 text, col3 text); -- Create schema schema_for_label. openGauss=# CREATE SCHEMA schema_for_label; -- Create view view_for_label. openGauss=# CREATE VIEW view_for_label AS SELECT 1; -- Create function func_for_label. openGauss=# CREATE FUNCTION func_for_label RETURNS TEXT AS $$ SELECT col1 FROM tb_for_label; $$ LANGUAGE SQL; -- Create a resource label based on a table. openGauss=# CREATE RESOURCE LABEL IF NOT EXISTS table_label add TABLE(public.tb_for_label); -- Create a resource label based on columns. openGauss=# CREATE RESOURCE LABEL IF NOT EXISTS column_label add COLUMN(public.tb_for_label.col1); -- Create a resource label based on a schema. openGauss=# CREATE RESOURCE LABEL IF NOT EXISTS schema_label add SCHEMA(schema_for_label); -- Create a resource label based on a view. openGauss=# CREATE RESOURCE LABEL IF NOT EXISTS view_label add VIEW(view_for_label); -- Create a resource label based on a function. openGauss=# CREATE RESOURCE LABEL IF NOT EXISTS func_label add FUNCTION(func_for_label); -- Drop resource labels. openGauss=# DROP RESOURCE LABEL func_label, view_label, schema_label, column_label, table_label; -- Drop the func_for_label function. openGauss=# DROP FUNCTION func_for_label; -- Drop the view_for_label view. openGauss=# DROP VIEW view_for_label; -- Drop the schema_for_label schema. openGauss=# DROP SCHEMA schema_for_label; -- Drop the tb_for_label table. openGauss=# DROP TABLE tb_for_label; |
Helpful Links
5.1.13.14.17-ALTER RESOURCE LABEL and 5.1.13.14.102-DROP RESOURCE LABEL
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.