diff --git a/docs/scalardb-sql/grammar.mdx b/docs/scalardb-sql/grammar.mdx index fe064d91..c7d5045f 100644 --- a/docs/scalardb-sql/grammar.mdx +++ b/docs/scalardb-sql/grammar.mdx @@ -30,27 +30,6 @@ displayed_sidebar: docsEnglish - [DROP USER](#drop-user) - [GRANT](#grant) - [REVOKE](#revoke) - - [CREATE ABAC_POLICY](#create-abac_policy) - - [ENABLE ABAC_POLICY](#enable-abac_policy) - - [DISABLE ABAC_POLICY](#disable-abac_policy) - - [CREATE ABAC_LEVEL](#create-abac_level) - - [DROP ABAC_LEVEL](#drop-abac_level) - - [CREATE ABAC_COMPARTMENT](#create-abac_compartment) - - [DROP ABAC_COMPARTMENT](#drop-abac_compartment) - - [CREATE ABAC_GROUP](#create-abac_group) - - [DROP ABAC_GROUP](#drop-abac_group) - - [SET ABAC_LEVEL](#set-abac_level) - - [ADD ABAC_COMPARTMENT](#add-abac_compartment) - - [REMOVE ABAC_COMPARTMENT](#remove-abac_compartment) - - [ADD ABAC_GROUP](#add-abac_group) - - [REMOVE ABAC_GROUP](#remove-abac_group) - - [DROP ABAC_USER_TAG_INFO](#drop-abac_user_tag_info) - - [CREATE ABAC_NAMESPACE_POLICY](#create-abac_namespace_policy) - - [ENABLE ABAC_NAMESPACE_POLICY](#enable-abac_namespace_policy) - - [DISABLE ABAC_NAMESPACE_POLICY](#disable-abac_namespace_policy) - - [CREATE ABAC_TABLE_POLICY](#create-abac_table_policy) - - [ENABLE ABAC_TABLE_POLICY](#enable-abac_table_policy) - - [DISABLE ABAC_TABLE_POLICY](#disable-abac_table_policy) - Others - [USE](#use) - [BEGIN](#begin) @@ -69,19 +48,6 @@ displayed_sidebar: docsEnglish - [RESUME](#resume) - [SHOW USERS](#show-users) - [SHOW GRANTS](#show-grants) - - [SHOW ABAC_POLICY](#show-abac_policy) - - [SHOW ABAC_POLICIES](#show-abac_policies) - - [SHOW ABAC_LEVEL](#show-abac_level) - - [SHOW ABAC_LEVELS](#show-abac_levels) - - [SHOW ABAC_COMPARTMENT](#show-abac_compartment) - - [SHOW ABAC_COMPARTMENTS](#show-abac_compartments) - - [SHOW ABAC_GROUP](#show-abac_group) - - [SHOW ABAC_GROUPS](#show-abac_groups) - - [SHOW ABAC_USER_TAG_INFO](#show-abac_user_tag_info) - - [SHOW ABAC_NAMESPACE_POLICY](#show-abac_namespace_policy) - - [SHOW ABAC_NAMESPACE_POLICIES](#show-abac_namespace_policies) - - [SHOW ABAC_TABLE_POLICY](#show-abac_table_policy) - - [SHOW ABAC_TABLE_POLICIES](#show-abac_table_policies) - Literal - [Text](#text) - [Numeric](#numeric) @@ -638,7 +604,7 @@ SELECT projection [, projection] ... [WHERE and_predicates [OR and_predicates ...] | or_predicates [AND or_predicates ...]] [ORDER BY identifier [order] [, identifier [order]] ...] [LIMIT ] - [WITH operation_attributes_or_abac_read_tags] + [WITH operation_attributes] projection: * | identifier [AS ] join_specification: [INNER] JOIN [.] [AS ] ON join_predicate [AND join_predicate] ... | {LEFT|RIGHT} [OUTER] JOIN [.]
[AS ] ON join_predicate [AND join_predicate] ... @@ -649,10 +615,8 @@ predicate: identifier operator | identifier BETWEEN AND .]
.] | [alias.] operator: = | <> | != | > | >= | < | <= order: ASC | DESC -operation_attributes_or_abac_read_tags: operation_attribute_or_abac_read_tag [AND operation_attribute_or_abac_read_tag] ... -operation_attribute_or_abac_read_tag: operation_attribute | abac_read_tag +operation_attributes: operation_attribute [AND operation_attribute] ... operation_attribute: = -abac_read_tag: ABAC_READ_TAG FOR [POLICY] ``` ##### Note @@ -746,12 +710,6 @@ SELECT * FROM ns.tbl WHERE c1 = ? AND c2 > ? AND c2 <= ? ORDER BY c2 ASC, c3 DES -- With operations attributes SELECT * FROM ns.tbl WHERE c1 = 10 AND c2 = 'aaa' AND c3 = 1.23 WITH 'attribute1' = 'value1' AND 'attribute2' = 'value2'; - --- With an ABAC read tag -SELECT * FROM ns.tbl WHERE c1 = 10 AND c2 = 'aaa' AND c3 = 1.23 WITH ABAC_READ_TAG 'read_tag1' FOR POLICY policy1; - --- With operations attributes and an ABAC read tag -SELECT * FROM ns.tbl WHERE c1 = 10 AND c2 = 'aaa' AND c3 = 1.23 WITH 'attribute1' = 'value1' AND 'attribute2' = 'value2' AND ABAC_READ_TAG 'read_tag1' FOR POLICY policy1; ``` Examples of building statement objects for `SELECT` are as follows: @@ -866,28 +824,6 @@ SelectStatement statement8 = .withAttribute("attribute1", "value1") .withAttribute("attribute2", "value2") .build(); - -// With an ABAC read tag -SelectStatement statement9 = - StatementBuilder.select() - .from("ns", "tbl") - .where(Predicate.column("c1").isEqualTo(Value.of(10))) - .and(Predicate.column("c2").isEqualTo(Value.of("aaa"))) - .and(Predicate.column("c3").isEqualTo(Value.of(1.23F))) - .withAbacReadTag("read_tag1", "policy1") - .build(); - -// With operations attributes and an ABAC read tag -SelectStatement statement10 = - StatementBuilder.select() - .from("ns", "tbl") - .where(Predicate.column("c1").isEqualTo(Value.of(10))) - .and(Predicate.column("c2").isEqualTo(Value.of("aaa"))) - .and(Predicate.column("c3").isEqualTo(Value.of(1.23F))) - .withAttribute("attribute1", "value1") - .withAttribute("attribute2", "value2") - .withAbacReadTag("read_tag1", "policy1") - .build(); ``` Examples of `SELECT` with `JOIN` are as follows: @@ -1238,13 +1174,10 @@ This command returns the following column: ```sql UPSERT INTO [.]
[( [, ] ...)] VALUES ( [, ] ...) [, ( [, ] ...)] ... - [WITH operation_attributes_or_abac_read_tags_or_abac_write_tags] + [WITH operation_attributes] -operation_attributes_or_abac_read_tags_or_abac_write_tags: operation_attribute_or_abac_read_tag_or_abac_write_tag [AND operation_attribute_or_abac_read_tag_or_abac_write_tag] ... -operation_attribute_or_abac_read_tag_or_abac_write_tag: operation_attribute | abac_read_tag | abac_write_tag +operation_attributes: operation_attribute [AND operation_attribute] ... operation_attribute: = -abac_read_tag: ABAC_READ_TAG FOR [POLICY] -abac_write_tag: ABAC_WRITE_TAG FOR [POLICY] ``` - You must specify a full primary key in `UPSERT`. @@ -1269,12 +1202,6 @@ UPSERT INTO ns.tbl (c1, c2, c3, c4) VALUES (10, 'aaa', 1.23, 100), (20, 'bbb', 4 -- With operations attributes UPSERT INTO ns.tbl VALUES (10, 'aaa', 1.23, 100, true) WITH 'attribute1' = 'value1' AND 'attribute2' = 'value2'; - --- With an ABAC read tag and an ABAC write tag -UPSERT INTO ns.tbl VALUES (10, 'aaa', 1.23, 100, true) WITH ABAC_READ_TAG 'read_tag1' FOR POLICY policy1 AND ABAC_WRITE_TAG 'write_tag1' FOR POLICY policy1; - --- With operations attributes and ABAC read and write tags -UPSERT INTO ns.tbl VALUES (10, 'aaa', 1.23, 100, true) WITH 'attribute1' = 'value1' AND 'attribute2' = 'value2' AND ABAC_READ_TAG 'read_tag1' FOR POLICY policy1 AND ABAC_WRITE_TAG 'write_tag1' FOR POLICY policy1; ``` Examples of building statement objects for `UPSERT` are as follows: @@ -1345,34 +1272,6 @@ UpsertStatement statement5 = .withAttribute("attribute1", "value1") .withAttribute("attribute2", "value2") .build(); - -// With an ABAC read tag and an ABAC write tag -UpsertStatement statement6 = - StatementBuilder.upsertInto("ns", "tbl") - .values( - Value.ofInt(10), - Value.ofText("aaa"), - Value.of(1.23F), - Value.of(100L), - Value.of(true)) - .withAbacReadTag("read_tag1", "policy1") - .withAbacWriteTag("write_tag1", "policy1") - .build(); - -// With operations attributes and ABAC read and write tags -UpsertStatement statement7 = - StatementBuilder.upsertInto("ns", "tbl") - .values( - Value.ofInt(10), - Value.ofText("aaa"), - Value.of(1.23F), - Value.of(100L), - Value.of(true)) - .withAttribute("attribute1", "value1") - .withAttribute("attribute2", "value2") - .withAbacReadTag("read_tag1", "policy1") - .withAbacWriteTag("write_tag1", "policy1") - .build(); ``` ### UPDATE @@ -1397,18 +1296,15 @@ This command returns the following column: UPDATE [.]
[AS ] SET = [, = ] ... [WHERE and_predicates [OR and_predicates ...] | or_predicates [AND or_predicates ...]] - [WITH operation_attributes_or_abac_read_tags_or_abac_write_tags] + [WITH operation_attributes] identifier: [[.]
.] | [alias.] and_predicates: predicate | (predicate [AND predicate ...]) or_predicates: predicate | (predicate [OR predicate ...]) predicate: operator | BETWEEN AND | [NOT] LIKE [ESCAPE ] | IS [NOT] NULL operator: = | <> | != | > | >= | < | <= -operation_attributes_or_abac_read_tags_or_abac_write_tags: operation_attribute_or_abac_read_tag_or_abac_write_tag [AND operation_attribute_or_abac_read_tag_or_abac_write_tag] ... -operation_attribute_or_abac_read_tag_or_abac_write_tag: operation_attribute | abac_read_tag | abac_write_tag +operation_attributes: operation_attribute [AND operation_attribute] ... operation_attribute: = -abac_read_tag: ABAC_READ_TAG FOR [POLICY] -abac_write_tag: ABAC_WRITE_TAG FOR [POLICY] ``` ##### Note @@ -1455,13 +1351,8 @@ UPDATE ns.tbl SET c4 = ?, c5 = ? WHERE c1 = ? AND c2 = ? AND c3 = ?; -- With operations attributes UPDATE ns.tbl SET c4 = 200, c5 = false WHERE c1 = 10 AND c2 = 'aaa' AND c3 = 1.23 WITH 'attribute1' = 'value1' AND 'attribute2' = 'value2'; - --- With an ABAC read tag and an ABAC write tag -UPDATE ns.tbl SET c4 = 200, c5 = false WHERE c1 = 10 AND c2 = 'aaa' AND c3 = 1.23 WITH ABAC_READ_TAG 'read_tag1' FOR POLICY policy1 AND ABAC_WRITE_TAG 'write_tag1' FOR POLICY policy1; - --- With operations attributes and ABAC read and write tags -UPDATE ns.tbl SET c4 = 200, c5 = false WHERE c1 = 10 AND c2 = 'aaa' AND c3 = 1.23 WITH 'attribute1' = 'value1' AND 'attribute2' = 'value2' AND ABAC_READ_TAG 'read_tag1' FOR POLICY policy1 AND ABAC_WRITE_TAG 'write_tag1' FOR POLICY policy1; ``` + Examples of building statement objects for `UPDATE` are as follows: ```java @@ -1499,34 +1390,6 @@ UpdateStatement statement3 = .withAttribute("attribute1", "value1") .withAttribute("attribute2", "value2") .build(); - -// With an ABAC read tag and an ABAC write tag -UpdateStatement statement4 = - StatementBuilder.update("ns", "tbl") - .set( - Assignment.column("c4").value(Value.of(200L)), - Assignment.column("c5").value(Value.of(false))) - .where(Predicate.column("c1").isEqualTo(Value.of(10))) - .and(Predicate.column("c2").isEqualTo(Value.of("aaa"))) - .and(Predicate.column("c3").isEqualTo(Value.of(1.23F))) - .withAbacReadTag("read_tag1", "policy1") - .withAbacWriteTag("write_tag1", "policy1") - .build(); - -// With operations attributes and ABAC read and write tags -UpdateStatement statement5 = - StatementBuilder.update("ns", "tbl") - .set( - Assignment.column("c4").value(Value.of(200L)), - Assignment.column("c5").value(Value.of(false))) - .where(Predicate.column("c1").isEqualTo(Value.of(10))) - .and(Predicate.column("c2").isEqualTo(Value.of("aaa"))) - .and(Predicate.column("c3").isEqualTo(Value.of(1.23F))) - .withAttribute("attribute1", "value1") - .withAttribute("attribute2", "value2") - .withAbacReadTag("read_tag1", "policy1") - .withAbacWriteTag("write_tag1", "policy1") - .build(); ``` #### Examples without the full primary key specified @@ -1679,18 +1542,15 @@ This command returns the following column: ```sql DELETE FROM [.]
[AS ] [WHERE and_predicates [OR and_predicates ...] | or_predicates [AND or_predicates ...]] - [WITH operation_attributes_or_abac_read_tags_or_abac_write_tags] + [WITH operation_attributes] identifier: [[.]
.] | [alias.] and_predicates: predicate | (predicate [AND predicate ...]) or_predicates: predicate | (predicate [OR predicate ...]) predicate: operator | BETWEEN AND | [NOT] LIKE [ESCAPE ] | IS [NOT] NULL operator: = | <> | != | > | >= | < | <= -operation_attributes_or_abac_read_tags_or_abac_write_tags: operation_attribute_or_abac_read_tag_or_abac_write_tag [AND operation_attribute_or_abac_read_tag_or_abac_write_tag] ... -operation_attribute_or_abac_read_tag_or_abac_write_tag: operation_attribute | abac_read_tag | abac_write_tag +operation_attributes: operation_attribute [AND operation_attribute] ... operation_attribute: = -abac_read_tag: ABAC_READ_TAG FOR [POLICY] -abac_write_tag: ABAC_WRITE_TAG FOR [POLICY] ``` ##### Note @@ -1737,12 +1597,6 @@ DELETE FROM tbl WHERE c1 = ? AND c2 = ? AND c3 = ?; -- With operations attributes DELETE FROM ns.tbl WHERE c1 = 10 AND c2 = 'aaa' AND c3 = 1.23 WITH 'attribute1' = 'value1' AND 'attribute2' = 'value2'; - --- With an ABAC read tag and an ABAC write tag -DELETE FROM ns.tbl WHERE c1 = 10 AND c2 = 'aaa' AND c3 = 1.23 WITH ABAC_READ_TAG 'read_tag1' FOR POLICY policy1 AND ABAC_WRITE_TAG 'write_tag1' FOR POLICY policy1; - --- With operations attributes and ABAC read and write tags -DELETE FROM ns.tbl WHERE c1 = 10 AND c2 = 'aaa' AND c3 = 1.23 WITH 'attribute1' = 'value1' AND 'attribute2' = 'value2' AND ABAC_READ_TAG 'read_tag1' FOR POLICY policy1 AND ABAC_WRITE_TAG 'write_tag1' FOR POLICY policy1; ``` Examples of building statement objects for `DELETE` are as follows: @@ -1773,28 +1627,6 @@ DeleteStatement statement3 = .withAttribute("attribute1", "value1") .withAttribute("attribute2", "value2") .build(); - -// With an ABAC read tag and an ABAC write tag -DeleteStatement statement4 = - StatementBuilder.deleteFrom("ns", "tbl") - .where(Predicate.column("c1").isEqualTo(Value.of(10))) - .and(Predicate.column("c2").isEqualTo(Value.of("aaa"))) - .and(Predicate.column("c3").isEqualTo(Value.of(1.23F))) - .withAbacReadTag("read_tag1", "policy1") - .withAbacWriteTag("write_tag1", "policy1") - .build(); - -// With operations attributes and ABAC read and write tags -DeleteStatement statement5 = - StatementBuilder.deleteFrom("ns", "tbl") - .where(Predicate.column("c1").isEqualTo(Value.of(10))) - .and(Predicate.column("c2").isEqualTo(Value.of("aaa"))) - .and(Predicate.column("c3").isEqualTo(Value.of(1.23F))) - .withAttribute("attribute1", "value1") - .withAttribute("attribute2", "value2") - .withAbacReadTag("read_tag1", "policy1") - .withAbacWriteTag("write_tag1", "policy1") - .build(); ``` #### Examples without the full primary key specified @@ -2168,1611 +2000,455 @@ RevokeStatement statement5 = .build(); ``` -### CREATE ABAC_POLICY +## Others + +### USE -The `CREATE ABAC_POLICY` command creates a new ABAC policy with the specified policy name and data tag column name. The newly added policy is enabled by default. +The `USE` command specifies a default namespace. If a namespace name is omitted in a SQL statement, the default namespace will be used. #### Grammar ```sql -CREATE ABAC_POLICY [WITH [DATA_TAG_COLUMN] ]; +USE ``` -- If you don't specify the data tag column name, the default data tag column name will be `_data_tag`. - #### Examples -Examples of `CREATE ABAC_POLICY` are as follows: +An example of `USE` is as follows: ```sql --- Create an ABAC policy with the default data tag column name. -CREATE ABAC_POLICY policy1; - --- Create an ABAC policy with a custom data tag column name. -CREATE ABAC_POLICY policy2 WITH DATA_TAG_COLUMN data_tag; +-- Specify a default namespace name "ns" +USE ns; ``` -Examples of building statement objects for `CREATE ABAC_POLICY` are as follows: +An example of building statement objects for `USE` is as follows: ```java -// Create an ABAC policy with the default data tag column name. -CreateAbacPolicyStatement statement1 = StatementBuilder.createAbacPolicy("policy1").build(); - -// Create an ABAC policy with a custom data tag column name. -CreateAbacPolicyStatement statement2 = - StatementBuilder.createAbacPolicy("policy1") - .withDataTagColumn("data_tag") - .build(); +// Specify a default namespace name "ns" +UseStatement statement = StatementBuilder.use("ns").build(); ``` +### BEGIN + +The `BEGIN` command begins a transaction. -### ENABLE ABAC_POLICY +This command returns the following column: -The `ENABLE ABAC_POLICY` command enables the specified ABAC policy. +- `transactionId`: `TEXT` - a transaction ID associated with the transaction you have begun #### Grammar ```sql -ENABLE ABAC_POLICY ; +BEGIN ``` #### Examples -An example of `ENABLE ABAC_POLICY` is as follows: +An example of building statement objects for `BEGIN` is as follows: -```sql --- Enable an ABAC policy. -ENABLE ABAC_POLICY policy1; +```java +// Begin a transaction +BeginStatement statement = StatementBuilder.begin().build(); ``` -An example of building statement objects for `ENABLE ABAC_POLICY` is as follows: +### START TRANSACTION -```java -// Enable an ABAC policy. -EnableAbacPolicyStatement statement = StatementBuilder.enableAbacPolicy("policy1").build(); -``` +The `START TRANSACTION` command starts a transaction. This command is an alias of `BEGIN`. -### DISABLE ABAC_POLICY +This command returns the following column: -The `DISABLE ABAC_POLICY` command disables the specified ABAC policy. This command effectively disables ABAC functionality for all namespaces and tables associated with the specified policy. +- `transactionId`: `TEXT` - the transaction ID associated with the transaction you have started #### Grammar ```sql -DISABLE ABAC_POLICY ; +START TRANSACTION ``` #### Examples -An example of `DISABLE ABAC_POLICY` is as follows: - -```sql --- Disable an ABAC policy. -DISABLE ABAC_POLICY policy1; -``` - -An example of building statement objects for `DISABLE ABAC_POLICY` is as follows: +An example of building statement objects for `START TRANSACTION` is as follows: ```java -// Disable an ABAC policy. -DisableAbacPolicyStatement statement = StatementBuilder.disableAbacPolicy("policy1").build(); +// Start a transaction. +StartTransactionStatement statement = StatementBuilder.startTransaction().build(); ``` -### CREATE ABAC_LEVEL +### JOIN -The `CREATE ABAC_LEVEL` command creates a new ABAC level with the specified level short name, long name, and level number in the specified policy. +The `JOIN` command joins a transaction associated with the specified transaction ID. #### Grammar ```sql -CREATE ABAC_LEVEL WITH [LONG_NAME] AND [LEVEL_NUMBER] IN [POLICY] ; +JOIN ``` #### Examples -An example of `CREATE ABAC_LEVEL` are as follows: +An example of `JOIN` is as follows: ```sql --- Create an ABAC level. -CREATE ABAC_LEVEL l1 WITH LONG_NAME level1 AND LEVEL_NUMBER 10 IN POLICY policy1; +-- Join a transaction +JOIN 'id'; ``` -An example of building statement objects for `CREATE ABAC_LEVEL` are as follows: +An example of building statement objects for `JOIN` is as follows: ```java -// Create an ABAC level. -CreateAbacLevelStatement statement = - StatementBuilder.createAbacLevel("l1") - .withLongName("level1") - .andLevelNumber(10) - .inPolicy("policy1") - .build(); +// Join a transaction +JoinStatement statement = StatementBuilder.join("id").build(); ``` -### DROP ABAC_LEVEL +### PREPARE -The `DROP ABAC_LEVEL` command drops the specified ABAC level in the specified policy. +The `PREPARE` command prepares the current transaction. #### Grammar ```sql -DROP ABAC_LEVEL IN [POLICY] ; +PREPARE ``` #### Examples -An example of `DROP ABAC_LEVEL` is as follows: - -```sql --- Drop an ABAC level. -DROP ABAC_LEVEL l1 IN POLICY policy1; -``` - -An example of building statement objects for `DROP ABAC_LEVEL` is as follows: +An example of building statement objects for `PREPARE` is as follows: ```java -// Drop an ABAC level. -DropAbacLevelStatement statement = - StatementBuilder.dropAbacLevel("l1").inPolicy("policy1").build(); +// Prepare the current transaction +PrepareStatement statement = StatementBuilder.prepare().build(); ``` -### CREATE ABAC_COMPARTMENT +### VALIDATE -The `CREATE ABAC_COMPARTMENT` command creates a new ABAC compartment with the specified compartment short name and long name in the specified policy. +The `VALIDATE` command validates the current transaction. #### Grammar ```sql -CREATE ABAC_COMPARTMENT WITH [LONG_NAME] IN [POLICY] ; +VALIDATE ``` #### Examples -An example of `CREATE ABAC_COMPARTMENT` are as follows: - -```sql --- Create an ABAC compartment. -CREATE ABAC_COMPARTMENT c1 WITH LONG_NAME compartment1 IN POLICY policy1; -``` - -An example of building statement objects for `CREATE ABAC_COMPARTMENT` are as follows: +An example of building statement objects for `VALIDATE` is as follows: ```java -// Create an ABAC compartment. -CreateAbacCompartmentStatement statement = - StatementBuilder.createAbacCompartment("c1") - .withLongName("compartment1") - .inPolicy("policy1") - .build(); +// Validate the current transaction +ValidateStatement statement = StatementBuilder.validate().build(); ``` -### DROP ABAC_COMPARTMENT +### COMMIT -The `DROP ABAC_COMPARTMENT` command drops the specified ABAC compartment in the specified policy. +The `COMMIT` command commits the current transaction. #### Grammar ```sql -DROP ABAC_COMPARTMENT IN [POLICY] ; +COMMIT ``` #### Examples -An example of `DROP ABAC_COMPARTMENT` is as follows: - -```sql --- Drop an ABAC compartment. -DROP ABAC_COMPARTMENT c1 IN POLICY policy1; -``` - -An example of building statement objects for `DROP ABAC_COMPARTMENT` is as follows: +An example of building statement objects for `COMMIT` is as follows: ```java -// Drop an ABAC compartment. -DropAbacCompartmentStatement statement = - StatementBuilder.dropAbacCompartment("c1").inPolicy("policy1").build(); +// Commit the current transaction +CommitStatement statement = StatementBuilder.commit().build(); ``` -### CREATE ABAC_GROUP +### ROLLBACK -The `CREATE ABAC_GROUP` command creates a new ABAC group with the specified short name, long name, and optionally a parent group, within the specified policy. +The `ROLLBACK` command rolls back the current transaction. #### Grammar ```sql -CREATE ABAC_GROUP WITH [LONG_NAME] [AND [PARENT_GROUP] ] IN [POLICY] ; +ROLLBACK ``` #### Examples -Examples of `CREATE ABAC_GROUP` are as follows: - -```sql --- Create an ABAC group with a parent group. -CREATE ABAC_GROUP g1 WITH LONG_NAME group1 AND PARENT_GROUP g0 IN POLICY policy1; - --- Create an ABAC group without a parent group. -CREATE ABAC_GROUP g2 WITH LONG_NAME group2 IN POLICY policy1; -``` - -Examples of building statement objects for `CREATE ABAC_GROUP` are as follows: +An example of building statement objects for `ROLLBACK` is as follows: ```java -// Create an ABAC group with a parent group. -CreateAbacGroupStatement statement1 = - StatementBuilder.createAbacGroup("g1") - .withLongName("group1") - .andParentGroup("g0") - .inPolicy("policy1") - .build(); - -// Create an ABAC group without a parent group. -CreateAbacGroupStatement statement2 = - StatementBuilder.createAbacGroup("g2").withLongName("group2").inPolicy("policy1").build(); +// Rollback the current transaction +RollbackStatement statement = StatementBuilder.rollback().build(); ``` -### DROP ABAC_GROUP +### ABORT -The `DROP ABAC_GROUP` command drops the specified ABAC group in the specified policy. +The `ABORT` command rolls back the current transaction. This command is an alias of `ROLLBACK`. #### Grammar ```sql -DROP ABAC_GROUP IN [POLICY] ; +ABORT ``` #### Examples -An example of `DROP ABAC_GROUP` is as follows: - -```sql --- Drop an ABAC group. -DROP ABAC_GROUP g1 IN POLICY policy1; -``` - -An example of building statement objects for `DROP ABAC_GROUP` is as follows: +An example of building statement objects for `ABORT` is as follows: ```java -// Drop an ABAC group. -DropAbacGroupStatement statement = - StatementBuilder.dropAbacGroup("g1").inPolicy("policy1").build(); +// Abort the current transaction. +AbortStatement statement = StatementBuilder.abort().build(); ``` -### SET ABAC_LEVEL +### SET MODE -The `SET ABAC_LEVEL` command sets the specified ABAC levels for the specified user in the specified policy. +The `SET MODE` command switches the current transaction mode. #### Grammar ```sql -SET ABAC_LEVEL [AND [DEFAULT_LEVEL] ] [AND [ROW_LEVEL] ] FOR [USER] IN [POLICY] ; -``` +SET MODE transaction_mode -- If you omit the default level, the level specified by `` will be used as the default level. -- If you omit the row level, the default level will be used as the row level. +transaction_mode: TRANSACTION | TWO_PHASE_COMMIT_TRANSACTION +``` #### Examples -Examples of `SET ABAC_LEVEL` are as follows: +An example of `SET MODE` is as follows: ```sql --- Set the levels for a user. -SET ABAC_LEVEL l1 AND DEFAULT_LEVEL l2 AND ROW_LEVEL l3 FOR USER user1 IN POLICY policy1; - --- Set the levels for a user without a row level. -SET ABAC_LEVEL l1 AND DEFAULT_LEVEL l2 FOR USER user1 IN POLICY policy1; - --- Set the levels for a user without a default level and a row level. -SET ABAC_LEVEL l1 FOR USER user1 IN POLICY policy1; +-- Switch the current transaction mode to Two-phase Commit Transaction +SET MODE TWO_PHASE_COMMIT_TRANSACTION; ``` -Examples of building statement objects for `SET ABAC_LEVEL` are as follows: +An example of building statement objects for `SET MODE` is as follows: ```java -// Set the levels for a user. -SetAbacLevelsForUserStatement statement1 = - StatementBuilder.setAbacLevel("l1") - .andDefaultLevel("l2") - .andRowLevel("l3") - .forUser("user1") - .inPolicy("policy1") - .build(); - -// Set the levels for a user without a row level. -SetAbacLevelsForUserStatement statement2 = - StatementBuilder.setAbacLevel("l1") - .andDefaultLevel("l2") - .forUser("user1") - .inPolicy("policy1") - .build(); - -// Set the levels for a user without a default level and a row level. -SetAbacLevelsForUserStatement statement3 = - StatementBuilder.setAbacLevel("l1").forUser("user1").inPolicy("policy1").build(); +// Switch the current transaction mode to Two-phase Commit Transaction +SetModeStatement statement = + StatementBuilder.setMode(TransactionMode.TWO_PHASE_COMMIT_TRANSACTION).build(); ``` -### ADD ABAC_COMPARTMENT +### SHOW NAMESPACES -The `ADD ABAC_COMPARTMENT` command adds the specified ABAC compartment to the specified user in the specified policy. +The `SHOW NAMESPACES` command shows namespace names. -#### Grammar +:::note -```sql -ADD ABAC_COMPARTMENT TO [USER] [WITH {accessMode [AND default] [AND row] | default [AND row] | row}] IN [POLICY] ; +This command extracts the namespace names of user tables dynamically. As a result, only namespaces that contain tables are returned. Starting from ScalarDB 4.0, we plan to improve the design to remove this limitation. -accessMode: READ_ONLY_ACCESS | READ_WRITE_ACCESS -default: DEFAULT [= {TRUE | FALSE}] -row: ROW [= {TRUE | FALSE}] -``` +::: -- If you omit the access mode, the default access mode will be `READ_ONLY_ACCESS`. -- If you omit the default part, the compartment will be in the default compartments. -- If you omit the row part, the compartment won't be in the row compartments. -- If you omit the boolean literal for `default` or `row`, the value of `default` or `row` will be set to `TRUE`. +This command returns the following column: -#### Examples +- `namespaceName`: `TEXT` - the namespace name -Examples of `ADD ABAC_COMPARTMENT` are as follows: +#### Grammar ```sql --- Add a compartment to a user without specifying the access mode, default, and row. -ADD ABAC_COMPARTMENT c1 TO USER user1 IN POLICY policy1; - --- Add a compartment to a user with the READ_WRITE_ACCESS access mode. -ADD ABAC_COMPARTMENT c1 TO USER user1 WITH READ_WRITE_ACCESS IN POLICY policy1; - --- Add a compartment to a user with specifying the default. -ADD ABAC_COMPARTMENT c1 TO USER user1 WITH DEFAULT IN POLICY policy1; - --- Add a compartment to a user with specifying the row to TRUE. -ADD ABAC_COMPARTMENT c1 TO USER user1 WITH ROW = TRUE IN POLICY policy1; +SHOW NAMESPACES ``` -Examples of building statement objects for `ADD ABAC_COMPARTMENT` are as follows: +#### Examples -```java -// Add a compartment to a user without specifying the access mode, default, and row. -AddAbacCompartmentToUserStatement statement1 = - StatementBuilder.addAbacCompartment("c1").toUser("user1").inPolicy("policy1").build(); +An example of building statement objects for `SHOW NAMESPACES` is as follows: -// Add a compartment to a user with the READ_WRITE_ACCESS access mode. -AddAbacCompartmentToUserStatement statement2 = - StatementBuilder.addAbacCompartment("c1") - .toUser("user1") - .withReadWriteAccess() - .inPolicy("policy1") - .build(); +```java +// Show namespace names. +ShowNamespacesStatement statement = StatementBuilder.showNamespaces().build(); +``` -// Add a compartment to a user with specifying the default. -AddAbacCompartmentToUserStatement statement3 = - StatementBuilder.addAbacCompartment("c1") - .toUser("user1") - .withDefault() - .inPolicy("policy1") - .build(); +### SHOW TABLES -// Add a compartment to a user with specifying the row to TRUE. -AddAbacCompartmentToUserStatement statement4 = - StatementBuilder.addAbacCompartment("c1") - .toUser("user1") - .withRow(true) - .inPolicy("policy1") - .build(); -``` +The `SHOW TABLES` command shows table names in a namespace. If a namespace name is omitted, the default namespace will be used. -### REMOVE ABAC_COMPARTMENT +This command returns the following column: -The `REMOVE ABAC_COMPARTMENT` command removes the specified compartment from the specified user in the specified policy. +- `tableName`: `TEXT` - a table name #### Grammar ```sql -REMOVE ABAC_COMPARTMENT FROM [USER] IN [POLICY] ; +SHOW TABLES [FROM ] ``` #### Examples -An example of `REMOVE ABAC_COMPARTMENT` is as follows: +Examples of `SHOW TABLES` is as follows: ```sql --- Remove a compartment from a user. -REMOVE ABAC_COMPARTMENT c1 FROM USER user1 IN POLICY policy1; -``` - -An example of building statement objects for `REMOVE ABAC_COMPARTMENT` is as follows: +-- Show table names in the default namespace +SHOW TABLES; -```java -// Remove a compartment from a user. -RemoveAbacCompartmentFromUserStatement statement = - StatementBuilder.removeAbacCompartment("c1").fromUser("user1").inPolicy("policy1").build(); +-- Show table names in a namespace "ns" +SHOW TABLES FROM ns; ``` -### ADD ABAC_GROUP - -The `ADD ABAC_GROUP` command adds the specified ABAC group to the specified user in the specified policy. - -#### Grammar - -```sql -ADD ABAC_GROUP TO [USER] [WITH {accessMode [AND default] [AND row] | default [AND row] | row}] IN [POLICY] ; - -accessMode: READ_ONLY_ACCESS | READ_WRITE_ACCESS -default: DEFAULT [= {TRUE | FALSE}] -row: ROW [= {TRUE | FALSE}] -``` - -- If you omit the access mode, the default access mode will be `READ_ONLY_ACCESS`. -- If you omit the default part, the group will be in the default compartments. -- If you omit the row part, the group won't be in the row compartments. -- If you omit the boolean literal for `default` or `row`, the value of `default` or `row` will be set to `TRUE`. - -#### Examples - -Examples of `ADD ABAC_GROUP` are as follows: - -```sql --- Add a group to a user without specifying the access mode, default, and row. -ADD ABAC_GROUP g1 TO USER user1 IN POLICY policy1; - --- Add a group to a user with the READ_WRITE_ACCESS access mode. -ADD ABAC_GROUP g1 TO USER user1 WITH READ_WRITE_ACCESS IN POLICY policy1; - --- Add a group to a user with specifying the default. -ADD ABAC_GROUP g1 TO USER user1 WITH DEFAULT IN POLICY policy1; - --- Add a group to a user with specifying the row to TRUE. -ADD ABAC_GROUP g1 TO USER user1 WITH ROW = TRUE IN POLICY policy1; -``` - -Examples of building statement objects for `ADD ABAC_GROUP_TO_USER` are as follows: - -```java -// Add a group to a user without specifying the access mode, default, and row. -AddAbacGroupToUserStatement statement1 = - StatementBuilder.addAbacGroup("g1").toUser("user1").inPolicy("policy1").build(); - -// Add a group to a user with the READ_WRITE_ACCESS access mode. -AddAbacGroupToUserStatement statement2 = - StatementBuilder.addAbacGroup("g1") - .toUser("user1") - .withReadWriteAccess() - .inPolicy("policy1") - .build(); - -// Add a group to a user with specifying the default. -AddAbacGroupToUserStatement statement3 = - StatementBuilder.addAbacGroup("g1") - .toUser("user1") - .withDefault() - .inPolicy("policy1") - .build(); - -// Add a group to a user with specifying the row to TRUE. -AddAbacGroupToUserStatement statement4 = - StatementBuilder.addAbacGroup("g1") - .toUser("user1") - .withRow(true) - .inPolicy("policy1") - .build(); -``` - -### REMOVE ABAC_GROUP - -The `REMOVE ABAC_GROUP` command removes the specified ABAC group from the specified user in the specified policy. - -#### Grammar - -```sql -REMOVE ABAC_GROUP FROM [USER] IN [POLICY] ; -``` - -#### Examples - -An example of `REMOVE ABAC_GROUP` is as follows: - -```sql --- Remove a group from a user. -REMOVE ABAC_GROUP g1 FROM USER user1 IN POLICY policy1; -``` - -An example of building statement objects for `REMOVE ABAC_GROUP` is as follows: - -```java -// Remove a group from a user. -RemoveAbacGroupFromUserStatement statement = - StatementBuilder.removeAbacGroup("g1").fromUser("user1").inPolicy("policy1").build(); -``` - -### DROP ABAC_USER_TAG_INFO - -The `DROP ABAC_USER_TAG_INFO` command drops the specified ABAC user tag information from the specified user in the specified policy. - -#### Grammar - -```sql -DROP ABAC_USER_TAG_INFO FROM [USER] IN [POLICY] ; -``` - -#### Examples - -An example of `DROP ABAC_USER_TAG_INFO` is as follows: - -```sql --- Drop user tag information from a user. -DROP ABAC_USER_TAG_INFO FROM USER user1 IN POLICY policy1; -``` - -An example of building statement objects for `DROP ABAC_USER_TAG_INFO` is as follows: - -```java -// Drop user tag information from a user. -DropAbacUserTagInfoFromUserStatement statement = - StatementBuilder.dropAbacUserTagInfoFromUser("user1").inPolicy("policy1").build(); -``` - -### CREATE ABAC_NAMESPACE_POLICY - -The `CREATE ABAC_NAMESPACE_POLICY` command creates a new ABAC namespace policy, with the specified namespace policy name using the specified policy and namespace. This command is used to apply the policy to the specified namespace. The newly added namespace policy is enabled by default. - -#### Grammar - -```sql -CREATE ABAC_NAMESPACE_POLICY USING [POLICY] AND [NAMESPACE] ; -``` - -#### Examples - -An example of `CREATE ABAC_NAMESPACE_POLICY` is as follows: - -```sql --- Create an ABAC namespace policy. -CREATE ABAC_NAMESPACE_POLICY ns_policy1 USING POLICY policy1 AND NAMESPACE ns; -``` - -An example of building statement objects for `CREATE ABAC_NAMESPACE_POLICY` is as follows: - -```java -// Create an ABAC namespace policy. -CreateAbacNamespacePolicyStatement statement = - StatementBuilder.createAbacNamespacePolicy("ns_policy1") - .usingPolicy("policy1") - .andNamespace("ns") - .build(); -``` - -### ENABLE ABAC_NAMESPACE_POLICY - -The `ENABLE ABAC_NAMESPACE_POLICY` command enables the specified ABAC namespace policy. - -#### Grammar - -```sql -ENABLE ABAC_NAMESPACE_POLICY ; -``` - -#### Examples - -An example of `ENABLE ABAC_NAMESPACE_POLICY` is as follows: - -```sql --- Enable an ABAC namespace policy. -ENABLE ABAC_NAMESPACE_POLICY ns_policy1; -``` - -An example of building statement objects for `ENABLE ABAC_NAMESPACE_POLICY` is as follows: - -```java -// Enable an ABAC namespace policy. -EnableAbacNamespacePolicyStatement statement = - StatementBuilder.enableAbacNamespacePolicy("ns_policy1").build(); -``` - -### DISABLE ABAC_NAMESPACE_POLICY - -The `DISABLE ABAC_NAMESPACE_POLICY` command disables the specified ABAC namespace policy. This command effectively disables ABAC functionality for the namespace associated with the specified namespace policy. - -#### Grammar - -```sql -DISABLE ABAC_NAMESPACE_POLICY ; -``` - -#### Examples - -An example of `DISABLE ABAC_NAMESPACE_POLICY` is as follows: - -```sql --- Disable an ABAC namespace policy. -DISABLE ABAC_NAMESPACE_POLICY ns_policy1; -``` - -An example of building statement objects for `DISABLE ABAC_NAMESPACE_POLICY` is as follows: - -```java -// Disable an ABAC namespace policy. -DisableAbacNamespacePolicyStatement statement = - StatementBuilder.disableAbacNamespacePolicy("ns_policy1").build(); -``` - -### CREATE ABAC_TABLE_POLICY - -The `CREATE ABAC_TABLE_POLICY` command creates a new ABAC table policy, with the specified table policy name using the specified policy and table. This command is used to apply the policy to the specified table. The newly added table policy is enabled by default. - -#### Grammar - -```sql -CREATE ABAC_TABLE_POLICY USING [POLICY] AND [TABLE] .; -``` - -#### Examples - -An example of `CREATE ABAC_TABLE_POLICY` is as follows: - -```sql --- Create an ABAC table policy. -CREATE ABAC_TABLE_POLICY tbl_policy1 USING POLICY policy1 AND TABLE ns.tbl; -``` - -An example of building statement objects for `CREATE ABAC_TABLE_POLICY` is as follows: - -```java -// Create an ABAC table policy. -CreateAbacTablePolicyStatement statement = - StatementBuilder.createAbacTablePolicy("tbl_policy1") - .usingPolicy("policy1") - .andTable("ns", "tbl") - .build(); -``` - -### ENABLE ABAC_TABLE_POLICY - -The `ENABLE ABAC_TABLE_POLICY` command enables the specified ABAC table policy. - -#### Grammar - -```sql -ENABLE ABAC_TABLE_POLICY ; -``` - -#### Examples - -An example of `ENABLE ABAC_TABLE_POLICY` is as follows: - -```sql --- Enable an ABAC table policy. -ENABLE ABAC_TABLE_POLICY tbl_policy1; -``` - -An example of building statement objects for `ENABLE ABAC_TABLE_POLICY` is as follows: - -```java -// Enable an ABAC table policy. -EnableAbacTablePolicyStatement statement = - StatementBuilder.enableAbacTablePolicy("tbl_policy1").build(); -``` - -### DISABLE ABAC_TABLE_POLICY - -The `DISABLE ABAC_TABLE_POLICY` command disables the specified ABAC table policy. This command effectively disables ABAC functionality for the table associated with the specified table policy. - -#### Grammar - -```sql -DISABLE ABAC_TABLE_POLICY ; -``` - -#### Examples - -An example of `DISABLE ABAC_TABLE_POLICY` is as follows: - -```sql --- Disable an ABAC table policy. -DISABLE ABAC_TABLE_POLICY tbl_policy1; -``` - -An example of building statement objects for `DISABLE ABAC_TABLE_POLICY` is as follows: - -```java -// Disable an ABAC table policy. -DisableAbacTablePolicyStatement statement = - StatementBuilder.disableAbacTablePolicy("tbl_policy1").build(); -``` - -## Others - -### USE - -The `USE` command specifies a default namespace. If a namespace name is omitted in a SQL statement, the default namespace will be used. - -#### Grammar - -```sql -USE -``` - -#### Examples - -An example of `USE` is as follows: - -```sql --- Specify a default namespace name "ns" -USE ns; -``` - -An example of building statement objects for `USE` is as follows: - -```java -// Specify a default namespace name "ns" -UseStatement statement = StatementBuilder.use("ns").build(); -``` - -### BEGIN - -The `BEGIN` command begins a transaction. - -This command returns the following column: - -- `transactionId`: `TEXT` - a transaction ID associated with the transaction you have begun - -#### Grammar - -```sql -BEGIN -``` - -#### Examples - -An example of building statement objects for `BEGIN` is as follows: - -```java -// Begin a transaction -BeginStatement statement = StatementBuilder.begin().build(); -``` - -### START TRANSACTION - -The `START TRANSACTION` command starts a transaction. This command is an alias of `BEGIN`. - -This command returns the following column: - -- `transactionId`: `TEXT` - the transaction ID associated with the transaction you have started - -#### Grammar - -```sql -START TRANSACTION -``` - -#### Examples - -An example of building statement objects for `START TRANSACTION` is as follows: - -```java -// Start a transaction. -StartTransactionStatement statement = StatementBuilder.startTransaction().build(); -``` - -### JOIN - -The `JOIN` command joins a transaction associated with the specified transaction ID. - -#### Grammar - -```sql -JOIN -``` - -#### Examples - -An example of `JOIN` is as follows: - -```sql --- Join a transaction -JOIN 'id'; -``` - -An example of building statement objects for `JOIN` is as follows: - -```java -// Join a transaction -JoinStatement statement = StatementBuilder.join("id").build(); -``` - -### PREPARE - -The `PREPARE` command prepares the current transaction. - -#### Grammar - -```sql -PREPARE -``` - -#### Examples - -An example of building statement objects for `PREPARE` is as follows: - -```java -// Prepare the current transaction -PrepareStatement statement = StatementBuilder.prepare().build(); -``` - -### VALIDATE - -The `VALIDATE` command validates the current transaction. - -#### Grammar - -```sql -VALIDATE -``` - -#### Examples - -An example of building statement objects for `VALIDATE` is as follows: - -```java -// Validate the current transaction -ValidateStatement statement = StatementBuilder.validate().build(); -``` - -### COMMIT - -The `COMMIT` command commits the current transaction. - -#### Grammar - -```sql -COMMIT -``` - -#### Examples - -An example of building statement objects for `COMMIT` is as follows: - -```java -// Commit the current transaction -CommitStatement statement = StatementBuilder.commit().build(); -``` - -### ROLLBACK - -The `ROLLBACK` command rolls back the current transaction. - -#### Grammar - -```sql -ROLLBACK -``` - -#### Examples - -An example of building statement objects for `ROLLBACK` is as follows: - -```java -// Rollback the current transaction -RollbackStatement statement = StatementBuilder.rollback().build(); -``` - -### ABORT - -The `ABORT` command rolls back the current transaction. This command is an alias of `ROLLBACK`. - -#### Grammar - -```sql -ABORT -``` - -#### Examples - -An example of building statement objects for `ABORT` is as follows: - -```java -// Abort the current transaction. -AbortStatement statement = StatementBuilder.abort().build(); -``` - -### SET MODE - -The `SET MODE` command switches the current transaction mode. - -#### Grammar - -```sql -SET MODE transaction_mode - -transaction_mode: TRANSACTION | TWO_PHASE_COMMIT_TRANSACTION -``` - -#### Examples - -An example of `SET MODE` is as follows: - -```sql --- Switch the current transaction mode to Two-phase Commit Transaction -SET MODE TWO_PHASE_COMMIT_TRANSACTION; -``` - -An example of building statement objects for `SET MODE` is as follows: - -```java -// Switch the current transaction mode to Two-phase Commit Transaction -SetModeStatement statement = - StatementBuilder.setMode(TransactionMode.TWO_PHASE_COMMIT_TRANSACTION).build(); -``` - -### SHOW NAMESPACES - -The `SHOW NAMESPACES` command shows namespace names. - -:::note - -This command extracts the namespace names of user tables dynamically. As a result, only namespaces that contain tables are returned. Starting from ScalarDB 4.0, we plan to improve the design to remove this limitation. - -::: - -This command returns the following column: - -- `namespaceName`: `TEXT` - the namespace name - -#### Grammar - -```sql -SHOW NAMESPACES -``` - -#### Examples - -An example of building statement objects for `SHOW NAMESPACES` is as follows: - -```java -// Show namespace names. -ShowNamespacesStatement statement = StatementBuilder.showNamespaces().build(); -``` - -### SHOW TABLES - -The `SHOW TABLES` command shows table names in a namespace. If a namespace name is omitted, the default namespace will be used. - -This command returns the following column: - -- `tableName`: `TEXT` - a table name - -#### Grammar - -```sql -SHOW TABLES [FROM ] -``` - -#### Examples - -Examples of `SHOW TABLES` is as follows: - -```sql --- Show table names in the default namespace -SHOW TABLES; - --- Show table names in a namespace "ns" -SHOW TABLES FROM ns; -``` - -Examples of building statement objects for `SHOW TABLES` is as follows: - -```java -// Show table names in the default namespace -ShowTablesStatement statement1 = StatementBuilder.showTables().build(); - -// Show table names in a namespace "ns" -ShowTablesStatement statement2 = StatementBuilder.showTables().from("ns").build(); -``` - -### DESCRIBE - -The `DESCRIBE` command returns column metadata for the specified table. - -This command returns the following columns: - -- `columnName`: `TEXT` - a table name -- `type`: `TEXT` - a type name -- `isPrimaryKey`: `BOOLEAN` - whether it's a column part of primary key -- `isPartitionKey`: `BOOLEAN` - whether it's a column part of partition key -- `isClusteringKey`: `BOOLEAN` - whether it's a column part of clustering key -- `clusteringOrder`: `TEXT` - a clustering order -- `isIndexed`: `BOOLEAN` - whether it's an indexed column - -#### Grammar - -```sql -DESCRIBE [.]
- -DESC [.]
-``` - -#### Examples - -Examples of `DESCRIBE` is as follows: - -```sql --- Returns column metadata for "ns.tbl" -DESCRIBE ns.tbl; - --- Returns column metadata for "tbl" -DESC tbl; -``` - -Examples of building statement objects for `DESCRIBE` is as follows: - -```java -// Returns column metadata for "ns.tbl" -DescribeStatement statement1 = StatementBuilder.describe("ns", "tbl").build(); - -// Returns column metadata for "tbl" -DescribeStatement statement2 = StatementBuilder.describe("tbl").build(); -``` - -### SUSPEND - -The `SUSPEND` command suspends the ongoing transaction in the current session. - -#### Grammar - -```sql -SUSPEND -``` - -#### Examples - -Examples of building statement objects for `SUSPEND` is as follows: - -```java -// Suspend the ongonig transaction in the current session -SuspendStatement statement = StatementBuilder.suspend().build(); -``` - -### RESUME - -The `RESUME` command resumes the transaction associated with the specified transaction ID in the current session. - -#### Grammar - -```sql -RESUME -``` - -#### Examples - -An example of `RESUME` is as follows: - -```sql --- Resume a transaction -RESUME 'id'; -``` - -An example of building statement objects for `RESUME` is as follows: - -```java -// Resume a transaction -ResumeStatement statement = StatementBuilder.resume("id").build(); -``` - -### SHOW USERS - -The `SHOW USERS` command shows usernames and user attributes. If you are a superuser, you can see all users. If you are a normal user, you can see only your own username and attributes. - -This command returns the following columns: - -- `username`: `TEXT` - a username -- `isSuperuser`: `BOOLEAN` - whether the user is a superuser - -#### Grammar - -```sql -SHOW USERS -``` - -#### Examples - -An example of `SHOW USERS` is as follows: - -```sql --- Show usernames and user attributes -SHOW USERS; -``` - -An example of building statement objects for `SHOW USERS` is as follows: - -```java -// Show usernames and user attributes -ShowUsersStatement statement = StatementBuilder.showUsers().build(); -``` - -### SHOW GRANTS - -The `SHOW GRANTS` command shows the privileges granted to the current user or the specified user. - -This command returns the following columns: - -- `name`: `TEXT` - a namespace name or a table name, depending on the type -- `type`: `TEXT` - the type of the object (either `NAMESPACE` or `TABLE`) -- `privilege`: `TEXT` - a privilege - -#### Grammar - -```sql --- Show privileges granted to the current user -SHOW GRANTS - --- Show privileges granted to the specified user -SHOW GRANTS FOR [USER] -``` - -#### Examples - -Examples of `SHOW GRANTS` are as follows: - -```sql --- Show privileges granted to the current user -SHOW GRANTS; - --- Show privileges granted to user1 -SHOW GRANTS FOR user1; -``` - -Examples of building statement objects for `SHOW GRANTS` are as follows: - -```java -// Show privileges granted to the current user -ShowGrantsStatement statement1 = StatementBuilder.showGrants().build(); - -// Show privileges granted to user1 -ShowGrantsStatement statement2 = StatementBuilder.showGrants().forUser("user1").build(); -``` - -### SHOW ABAC_POLICY - -The `SHOW ABAC_POLICY` command shows the specified ABAC policy. - -This command returns the following columns: - -- `name`: `TEXT` - the policy name -- `dataTagColumnName`: `TEXT` - the data tag column name -- `state`: `TEXT` - the state of the policy (either `ENABLED` or `DISABLED`) - -#### Grammar - -```sql -SHOW ABAC_POLICY ; -``` - -#### Examples - -An example of `SHOW ABAC_POLICY` is as follows: - -```sql --- Show the specified ABAC policy -SHOW ABAC_POLICY policy1; -``` - -An example of building statement objects for `SHOW ABAC_POLICY` is as follows: +Examples of building statement objects for `SHOW TABLES` is as follows: ```java -// Show the specified ABAC policy -ShowAbacPolicyStatement statement = StatementBuilder.showAbacPolicy("policy1").build(); -``` - -### SHOW ABAC_POLICIES - -The `SHOW ABAC_POLICIES` command shows all ABAC policies. - -This command returns the following columns: - -- `name`: `TEXT` - the policy name -- `dataTagColumnName`: `TEXT` - the data tag column name -- `state`: `TEXT` - the state of the policy (either `ENABLED` or `DISABLED`) - -#### Grammar - -```sql -SHOW ABAC_POLICIES; -``` - -#### Examples - -An example of `SHOW ABAC_POLICIES` is as follows: - -```sql --- Show all ABAC policies -SHOW ABAC_POLICIES; -``` - -An example of building statement objects for `SHOW ABAC_POLICIES` is as follows: +// Show table names in the default namespace +ShowTablesStatement statement1 = StatementBuilder.showTables().build(); -```java -// Show all ABAC policies -ShowAbacPoliciesStatement statement = StatementBuilder.showAbacPolicies().build(); +// Show table names in a namespace "ns" +ShowTablesStatement statement2 = StatementBuilder.showTables().from("ns").build(); ``` -### SHOW ABAC_LEVEL +### DESCRIBE -The `SHOW ABAC_LEVEL` command shows the specified ABAC level in the specified policy. +The `DESCRIBE` command returns column metadata for the specified table. This command returns the following columns: -- `policyName`: `TEXT` - the policy name -- `shortName`: `TEXT` - the short name of the level -- `longName`: `TEXT` - the long name of the level -- `levelNumber`: `INTEGER` - the level number of the level +- `columnName`: `TEXT` - a table name +- `type`: `TEXT` - a type name +- `isPrimaryKey`: `BOOLEAN` - whether it's a column part of primary key +- `isPartitionKey`: `BOOLEAN` - whether it's a column part of partition key +- `isClusteringKey`: `BOOLEAN` - whether it's a column part of clustering key +- `clusteringOrder`: `TEXT` - a clustering order +- `isIndexed`: `BOOLEAN` - whether it's an indexed column #### Grammar ```sql -SHOW ABAC_LEVEL IN [POLICY] ; -``` - -#### Examples - -An example of `SHOW ABAC_LEVEL` is as follows: - -```sql --- Show the specified ABAC level in the specified policy -SHOW ABAC_LEVEL l1 IN POLICY policy1; -``` - -An example of building statement objects for `SHOW ABAC_LEVEL` is as follows: - -```java -// Show the specified ABAC level in the specified policy -ShowAbacLevelStatement statement = StatementBuilder.showAbacLevel("l1").inPolicy("policy1").build(); -``` - -### SHOW ABAC_LEVELS - -The `SHOW ABAC_LEVELS` command shows all ABAC levels in the specified policy. - -This command returns the following columns: - -- `policyName`: `TEXT` - the policy name -- `shortName`: `TEXT` - the short name of the level -- `longName`: `TEXT` - the long name of the level -- `levelNumber`: `INTEGER` - the level number of the level - -#### Grammar +DESCRIBE [.]
-```sql -SHOW ABAC_LEVELS IN [POLICY] ; +DESC [.]
``` #### Examples -An example of `SHOW ABAC_LEVELS` is as follows: - -```sql --- Show all ABAC levels in the specified policy -SHOW ABAC_LEVELS IN POLICY policy1; -``` - -An example of building statement objects for `SHOW ABAC_LEVELS` is as follows: - -```java -// Show all ABAC levels in the specified policy -ShowAbacLevelsStatement statement = StatementBuilder.showAbacLevelsInPolicy("policy1").build(); -``` - -### SHOW ABAC_COMPARTMENT - -The `SHOW ABAC_COMPARTMENT` command shows the specified ABAC compartment in the specified policy. - -This command returns the following columns: - -- `policyName`: `TEXT` - the policy name -- `shortName`: `TEXT` - the short name of the compartment -- `longName`: `TEXT` - the long name of the compartment - -#### Grammar +Examples of `DESCRIBE` is as follows: ```sql -SHOW ABAC_COMPARTMENT IN [POLICY] ; -``` - -#### Examples - -An example of `SHOW ABAC_COMPARTMENT` is as follows: +-- Returns column metadata for "ns.tbl" +DESCRIBE ns.tbl; -```sql --- Show the specified ABAC compartment in the specified policy -SHOW ABAC_COMPARTMENT c1 IN POLICY policy1; +-- Returns column metadata for "tbl" +DESC tbl; ``` -An example of building statement objects for `SHOW ABAC_COMPARTMENT` is as follows: +Examples of building statement objects for `DESCRIBE` is as follows: ```java -// Show the specified ABAC compartment in the specified policy -ShowAbacCompartmentStatement statement = - StatementBuilder.showAbacCompartment("c1").inPolicy("policy1").build(); -``` - -### SHOW ABAC_COMPARTMENTS - -The `SHOW ABAC_COMPARTMENTS` command shows all ABAC compartments in the specified policy. - -This command returns the following columns: - -- `policyName`: `TEXT` - the policy name -- `shortName`: `TEXT` - the short name of the compartment -- `longName`: `TEXT` - the long name of the compartment - -#### Grammar - -```sql -SHOW ABAC_COMPARTMENTS IN [POLICY] ; -``` - -#### Examples - -An example of `SHOW ABAC_COMPARTMENTS` is as follows: - -```sql --- Show all ABAC compartments in the specified policy -SHOW ABAC_COMPARTMENTS IN POLICY policy1; -``` - -An example of building statement objects for `SHOW ABAC_COMPARTMENTS` is as follows: +// Returns column metadata for "ns.tbl" +DescribeStatement statement1 = StatementBuilder.describe("ns", "tbl").build(); -```java -// Show all ABAC compartments in the specified policy -ShowAbacCompartmentsStatement statement = - StatementBuilder.showAbacCompartmentsInPolicy("policy1").build(); +// Returns column metadata for "tbl" +DescribeStatement statement2 = StatementBuilder.describe("tbl").build(); ``` -### SHOW ABAC_GROUP - -The `SHOW ABAC_GROUP` command shows the specified ABAC group in the specified policy. - -This command returns the following columns: +### SUSPEND -- `policyName`: `TEXT` - the policy name -- `shortName`: `TEXT` - the short name of the group -- `longName`: `TEXT` - the long name of the group -- `parentGroupShortName`: `TEXT` - the short name of the parent group. If the group has no parent group, this column will be `null` +The `SUSPEND` command suspends the ongoing transaction in the current session. #### Grammar ```sql -SHOW ABAC_GROUP IN [POLICY] ; +SUSPEND ``` #### Examples -An example of `SHOW ABAC_GROUP` is as follows: - -```sql --- Show the specified ABAC group in the specified policy -SHOW ABAC_GROUP g1 IN POLICY policy1; -``` - -An example of building statement objects for `SHOW ABAC_GROUP` is as follows: +Examples of building statement objects for `SUSPEND` is as follows: ```java -// Show the specified ABAC group in the specified policy -ShowAbacGroupStatement statement = - StatementBuilder.showAbacGroup("g1").inPolicy("policy1").build(); +// Suspend the ongonig transaction in the current session +SuspendStatement statement = StatementBuilder.suspend().build(); ``` -### SHOW ABAC_GROUPS - -The `SHOW ABAC_GROUPS` command shows all ABAC groups in the specified policy. - -This command returns the following columns: +### RESUME -- `policyName`: `TEXT` - the policy name -- `shortName`: `TEXT` - the short name of the group -- `longName`: `TEXT` - the long name of the group -- `parentGroupShortName`: `TEXT` - the short name of the parent group. If the group has no parent group, this column will be `null` +The `RESUME` command resumes the transaction associated with the specified transaction ID in the current session. #### Grammar ```sql -SHOW ABAC_GROUPS IN [POLICY] ; +RESUME ``` #### Examples -An example of `SHOW ABAC_GROUPS` is as follows: +An example of `RESUME` is as follows: ```sql --- Show all ABAC groups in the specified policy -SHOW ABAC_GROUPS IN POLICY policy1; +-- Resume a transaction +RESUME 'id'; ``` -An example of building statement objects for `SHOW ABAC_GROUPS` is as follows: +An example of building statement objects for `RESUME` is as follows: ```java -// Show all ABAC groups in the specified policy -ShowAbacGroupsStatement statement = StatementBuilder.showAbacGroupsInPolicy("policy1").build(); +// Resume a transaction +ResumeStatement statement = StatementBuilder.resume("id").build(); ``` -### SHOW ABAC_USER_TAG_INFO +### SHOW USERS -The `SHOW ABAC_USER_TAG_INFO` command shows the ABAC user tag information for the specified user in the specified policy. +The `SHOW USERS` command shows usernames and user attributes. If you are a superuser, you can see all users. If you are a normal user, you can see only your own username and attributes. This command returns the following columns: -- `policyName`: `TEXT` - the policy name -- `username`: `TEXT` - the username -- `readTag`: `TEXT` - the read tag -- `writeTag`: `TEXT` - the write tag -- `defaultReadTag`: `TEXT` - the default read tag -- `defaultWriteTag`: `TEXT` - the default write tag -- `rowTag`: `TEXT` - the row tag +- `username`: `TEXT` - a username +- `isSuperuser`: `BOOLEAN` - whether the user is a superuser #### Grammar ```sql -SHOW ABAC_USER_TAG_INFO [FOR USER ] IN [POLICY] ; +SHOW USERS ``` -- If you omit the user, the user tag info for the current user will be displayed. - #### Examples -Examples of `SHOW ABAC_USER_TAG_INFO` are as follows: +An example of `SHOW USERS` is as follows: ```sql --- Show the ABAC user tag information for the current user in the specified policy -SHOW ABAC_USER_TAG_INFO IN POLICY policy1; - --- Show the ABAC user tag information for user1 in the specified policy -SHOW ABAC_USER_TAG_INFO FOR USER user1 IN POLICY policy1; +-- Show usernames and user attributes +SHOW USERS; ``` -Examples of building statement objects for `SHOW ABAC_USER_TAG_INFO` are as follows: +An example of building statement objects for `SHOW USERS` is as follows: ```java -// Show the ABAC user tag information for the current user in the specified policy -ShowAbacUserTagInfoStatement statement1 = - StatementBuilder.showAbacUserTagInfo().inPolicy("policy1").build(); - -// Show the ABAC user tag information for user1 in the specified policy -ShowAbacUserTagInfoStatement statement2 = - StatementBuilder.showAbacUserTagInfo().forUser("user1").inPolicy("policy1").build(); +// Show usernames and user attributes +ShowUsersStatement statement = StatementBuilder.showUsers().build(); ``` -### SHOW ABAC_NAMESPACE_POLICY +### SHOW GRANTS -The `SHOW ABAC_NAMESPACE_POLICY` command shows the specified ABAC namespace policy. +The `SHOW GRANTS` command shows the privileges granted to the current user or the specified user. This command returns the following columns: -- `name`: `TEXT` - the name of the namespace policy -- `policyName`: `TEXT` - the policy name -- `namespaceName`: `TEXT` - the namespace name -- `state`: `TEXT` - the state of the policy (either `ENABLED` or `DISABLED`) +- `name`: `TEXT` - a namespace name or a table name, depending on the type +- `type`: `TEXT` - the type of the object (either `NAMESPACE` or `TABLE`) +- `privilege`: `TEXT` - a privilege #### Grammar ```sql -SHOW ABAC_NAMESPACE_POLICY ; -``` - -#### Examples - -An example of `SHOW ABAC_NAMESPACE_POLICY` is as follows: - -```sql --- Show the specified ABAC namespace policy -SHOW ABAC_NAMESPACE_POLICY ns_policy1; -``` - -An example of building statement objects for `SHOW ABAC_NAMESPACE_POLICY` is as follows: - -```java -// Show the specified ABAC namespace policy -ShowAbacNamespacePolicyStatement statement = - StatementBuilder.showAbacNamespacePolicy("ns_policy1").build(); -``` - -### SHOW ABAC_NAMESPACE_POLICIES - -The `SHOW ABAC_NAMESPACE_POLICIES` command shows all ABAC namespace policies. - -This command returns the following columns: - -- `name`: `TEXT` - the name of the namespace policy -- `policyName`: `TEXT` - the policy name -- `namespaceName`: `TEXT` - the namespace name -- `state`: `TEXT` - the state of the policy (either `ENABLED` or `DISABLED`) - -#### Grammar +-- Show privileges granted to the current user +SHOW GRANTS -```sql -SHOW ABAC_NAMESPACE_POLICIES +-- Show privileges granted to the specified user +SHOW GRANTS FOR [USER] ``` #### Examples -An example of `SHOW ABAC_NAMESPACE_POLICIES` is as follows: - -```sql --- Show all ABAC namespace policies -SHOW ABAC_NAMESPACE_POLICIES; -``` - -An example of building statement objects for `SHOW ABAC_NAMESPACE_POLICIES` is as follows: - -```java -// Show all ABAC namespace policies -ShowAbacNamespacePoliciesStatement statement = - StatementBuilder.showAbacNamespacePolicies().build(); -``` - -### SHOW ABAC_TABLE_POLICY - -The `SHOW ABAC_TABLE_POLICY` command shows the specified ABAC table policy. - -This command returns the following columns: - -- `name`: `TEXT` - the name of the table policy -- `policyName`: `TEXT` - the policy name -- `namespaceName`: `TEXT` - the namespace name -- `tableName`: `TEXT` - the table name -- `state`: `TEXT` - the state of the policy (either `ENABLED` or `DISABLED`) - -#### Grammar +Examples of `SHOW GRANTS` are as follows: ```sql -SHOW ABAC_TABLE_POLICY ; -``` - -#### Examples - -An example of `SHOW ABAC_TABLE_POLICY` is as follows: +-- Show privileges granted to the current user +SHOW GRANTS; -```sql --- Show the specified ABAC table policy -SHOW ABAC_TABLE_POLICY tbl_policy1; +-- Show privileges granted to user1 +SHOW GRANTS FOR user1; ``` -An example of building statement objects for `SHOW ABAC_TABLE_POLICY` is as follows: +Examples of building statement objects for `SHOW GRANTS` are as follows: ```java -// Show the specified ABAC table policy -ShowAbacTablePolicyStatement statement = - StatementBuilder.showAbacTablePolicy("tbl_policy1").build(); -``` - -### SHOW ABAC_TABLE_POLICIES - -The `SHOW ABAC_TABLE_POLICIES` command shows all ABAC table policies. - -This command returns the following columns: - -- `name`: `TEXT` - the name of the table policy -- `policyName`: `TEXT` - the policy name -- `namespaceName`: `TEXT` - the namespace name -- `tableName`: `TEXT` - the table name -- `state`: `TEXT` - the state of the policy (either `ENABLED` or `DISABLED`) - -#### Grammar - -```sql -SHOW ABAC_TABLE_POLICIES; -``` - -#### Examples - -An example of `SHOW ABAC_TABLE_POLICIES` is as follows: - -```sql --- Show all ABAC table policies -SHOW ABAC_TABLE_POLICIES; -``` - -An example of building statement objects for `SHOW ABAC_TABLE_POLICIES` is as follows: +// Show privileges granted to the current user +ShowGrantsStatement statement1 = StatementBuilder.showGrants().build(); -```java -// Show all ABAC table policies -ShowAbacTablePoliciesStatement statement = StatementBuilder.showAbacTablePolicies().build(); +// Show privileges granted to user1 +ShowGrantsStatement statement2 = StatementBuilder.showGrants().forUser("user1").build(); ``` ## Literal