DCL
Data Control Language (DCL) manages database roles and permissions in Lindorm Cassandra Query Language (CQL). Use DCL statements to create and delete roles, list roles, and grant or revoke permissions.
Manage database roles
In Lindorm CQL, database roles control user access and permissions. Define a role name using the following grammar:
role_name ::= identifier | stringLindorm CQL and Apache Cassandra CQL support similar role management operations. By default, a new database role has no logon permissions and no superuser permissions.
Manage permissions
Lindorm CQL uses a permission hierarchy: granting a permission at a higher resource level automatically applies it to all lower-level resources. For example, granting SELECT on ALL KEYSPACES also grants SELECT on every table in every keyspace.
After permissions change, existing client connections remain valid — clients do not need to reconnect.
Lindorm CQL supports five permission types: CREATE, ALTER, DROP, SELECT, and MODIFY.
Each permission is valid only for specific resource types. Granting a permission on an unsupported resource returns an error.
The following table maps each permission to its supported resources and statements.
| Permission | Resource | Supported statement |
|---|---|---|
CREATE | ALL KEYSPACES | CREATE KEYSPACES and CREATE TABLE |
CREATE | KEYSPACE | CREATE TABLE |
ALTER | ALL KEYSPACES | ALTER KEYSPACES and ALTER TABLE |
ALTER | KEYSPACE | ALTER TABLE |
DROP | ALL KEYSPACES | DROP KEYSPACES and DROP TABLE |
DROP | KEYSPACE | DROP TABLE |
SELECT | ALL KEYSPACES | SELECT KEYSPACES and SELECT TABLE |
SELECT | KEYSPACE | SELECT TABLE |
SELECT | TABLE | SELECT |
MODIFY | ALL KEYSPACES | MODIFY KEYSPACES and MODIFY TABLE |
MODIFY | KEYSPACE | MODIFY TABLE |
MODIFY | TABLE | MODIFY |
CREATE ROLE
Creates a database role.
Syntax
create_role_statement ::= CREATE ROLE [ IF NOT EXISTS ] role_name
[ WITH role_options ]
role_options ::= role_option ( AND role_option )*
role_option ::= PASSWORD '=' string
| LOGIN '=' boolean
| SUPERUSER '=' boolean
| OPTIONS '=' map_literalParameters
| Parameter | Description |
|---|---|
role_name | The name of the database role. |
PASSWORD | Required. The password the role uses to log on to the database. |
LOGIN | Specifies whether the role has logon permissions. Default: false. When a client connects using a role with LOGIN = true, the client assumes that role and inherits all of its permissions. |
SUPERUSER | Specifies whether the role is a superuser. Default: false. A superuser can: create other superusers; run DROP KEYSPACE, DROP TABLE, and TRUNCATE; grant permissions on keyspaces and tables; and create permission hierarchies. |
Examples
Create a role with logon permissions:
CREATE ROLE readonly_user WITH PASSWORD = 'password_a' AND LOGIN = true;Create a superuser role with logon permissions:
CREATE ROLE admin_role WITH PASSWORD = 'password_b' AND LOGIN = true AND SUPERUSER = true;DROP ROLE
Deletes a database role.
Syntax
drop_role_statement ::= DROP ROLE [ IF EXISTS ] role_nameTo delete a role, you must have the DELETE permission on that role. Only a superuser can delete a role that has SUPERUSER set to true. A role that is currently logged on cannot be deleted.
The IF EXISTS clause controls behavior when the target role does not exist:
Without
IF EXISTS: the statement returns an error.With
IF EXISTS: the statement is a no-op.
Parameters
| Parameter | Description |
|---|---|
role_name | The name of the database role to delete. |
Examples
Delete a role (returns an error if the role does not exist):
DROP ROLE bob;Delete a role only if it exists:
DROP ROLE IF EXISTS bob;LIST ROLES
Lists database roles.
Syntax
list_roles_statement ::= LIST ROLES [ OF role_name ]Parameters
| Parameter | Description |
|---|---|
role_name | (Optional) The role to query. Returns the details of that role. |
Examples
List all roles in the system (superusers only):
LIST ROLES;List all roles granted to role1:
LIST ROLES OF role1;GRANT PERMISSION
Grants permissions to a database role.
Syntax
grant_permission_statement ::= GRANT permissions ON resource TO role_name
permissions ::= ALL [ PERMISSIONS ] | permission [ PERMISSION ]
permission ::= CREATE | ALTER | DROP | SELECT | MODIFY
resource ::= ALL KEYSPACES
| KEYSPACE keyspace_name
| [ TABLE ] table_nameParameters
| Parameter | Description |
|---|---|
permission | The permission to grant: CREATE, ALTER, DROP, SELECT, or MODIFY. Use ALL PERMISSIONS to grant all five permissions at once. |
resource | The resource scope: ALL KEYSPACES, KEYSPACE keyspace_name, or TABLE table_name (the TABLE keyword is optional). |
keyspace_name | The name of the keyspace. |
table_name | The name of the table. |
role_name | The role to receive the permission. |
Examples
Grant SELECT on all keyspaces to readonly_user, so the role can run SELECT on any table in the system:
GRANT SELECT ON ALL KEYSPACES TO readonly_user;Grant SELECT on a specific keyspace to readonly_user, so the role can run SELECT on any table in ks:
GRANT SELECT ON KEYSPACE ks TO readonly_user;REVOKE PERMISSION
Revokes permissions from a database role.
Syntax
revoke_permission_statement ::= REVOKE permissions ON resource FROM role_nameParameters
| Parameter | Description |
|---|---|
permission | The permission to revoke: CREATE, ALTER, DROP, SELECT, or MODIFY. Use ALL PERMISSIONS to revoke all five permissions at once. |
resource | The resource scope: ALL KEYSPACES, KEYSPACE keyspace_name, or TABLE table_name. |
role_name | The role from which to revoke the permission. |
Examples
Revoke SELECT on all keyspaces from readonly_user:
REVOKE SELECT ON ALL KEYSPACES FROM readonly_user;LIST PERMISSIONS
Lists permissions granted on each resource.
Syntax
list_permissions_statement ::= LIST permissions [ ON resource ] [ OF role_name ]OF role_name is required by default. Only a superuser can run LIST PERMISSIONS without specifying a role. Without ON resource, the statement returns the role's permissions on all resources.
Parameters
| Parameter | Description |
|---|---|
permissions | The permission types to list: CREATE, ALTER, DROP, SELECT, MODIFY, or ALL PERMISSIONS. |
resource | (Optional) Filter results to a specific resource: ALL KEYSPACES, KEYSPACE keyspace_name, or TABLE table_name. |
role_name | The role whose permissions to list. |
Examples
List all permissions held by readonly_user across all resources:
LIST ALL PERMISSIONS OF readonly_user;List all permissions readonly_user holds on keyspace kss:
LIST ALL PERMISSIONS ON KEYSPACE kss OF readonly_user;