Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Data Control Language | Some Additional Topics
Advanced Techniques in SQL

Data Control LanguageData Control Language

Data Control Language (DCL) is a subset of SQL used to control access to data stored in a relational database management system.
DCL commands are primarily concerned with granting or revoking privileges on database objects such as tables, views, and schemas.

DCL commands

The two main DCL commands are:

  1. GRANT: This command is used to give specific privileges to users or roles;
  2. REVOKE: This command is used to remove specific privileges from users or roles that have been previously granted.

Privileges

Privilege Description
SELECT Read data from a table or view.
INSERT Insert data into a table.
UPDATE Update data in a table.
DELETE Delete data from a table.
EXECUTE Execute stored procedures or functions.
ALL PRIVILEGES Grant all available privileges on an object.
CREATE Create new objects within a database or schema.
CONNECT Connect to a database.

Objects

Object Description
Tables Control data manipulation operations.
Views Control access to underlying data.
Schemas Control access to all objects within a schema.
Databases Control access to entire databases.

Implementation

To grant some privileges for an object in SQL for a particular user we can use the following statement:

There are 3 types of roles in DB to which you can grant some privileges:

  • user: An individual database user;
  • role: A database role, a named group of privileges that can be assigned to users (e.g. admin, developer, analyst);
  • PUBLIC: A special keyword that grants the specified privileges to all users.

We can grant a role to a user using the following statement:

Finally, we can revoke previously granted privileges using the following statement:


Example

Here are some examples of how to use the GRANT command to assign different privileges on the bankaccounts and userlogs tables to different roles and users.

Now we can revoke some of the granted privileges:

What privilege allows a user to read data from a table?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 6
course content

Зміст курсу

Advanced Techniques in SQL

Data Control LanguageData Control Language

Data Control Language (DCL) is a subset of SQL used to control access to data stored in a relational database management system.
DCL commands are primarily concerned with granting or revoking privileges on database objects such as tables, views, and schemas.

DCL commands

The two main DCL commands are:

  1. GRANT: This command is used to give specific privileges to users or roles;
  2. REVOKE: This command is used to remove specific privileges from users or roles that have been previously granted.

Privileges

Privilege Description
SELECT Read data from a table or view.
INSERT Insert data into a table.
UPDATE Update data in a table.
DELETE Delete data from a table.
EXECUTE Execute stored procedures or functions.
ALL PRIVILEGES Grant all available privileges on an object.
CREATE Create new objects within a database or schema.
CONNECT Connect to a database.

Objects

Object Description
Tables Control data manipulation operations.
Views Control access to underlying data.
Schemas Control access to all objects within a schema.
Databases Control access to entire databases.

Implementation

To grant some privileges for an object in SQL for a particular user we can use the following statement:

There are 3 types of roles in DB to which you can grant some privileges:

  • user: An individual database user;
  • role: A database role, a named group of privileges that can be assigned to users (e.g. admin, developer, analyst);
  • PUBLIC: A special keyword that grants the specified privileges to all users.

We can grant a role to a user using the following statement:

Finally, we can revoke previously granted privileges using the following statement:


Example

Here are some examples of how to use the GRANT command to assign different privileges on the bankaccounts and userlogs tables to different roles and users.

Now we can revoke some of the granted privileges:

What privilege allows a user to read data from a table?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 6
some-alt