Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
modul:m290:learningunits:lu06:aufgaben:a01 [2024/10/28 14:34] – vdemir | modul:m290:learningunits:lu06:aufgaben:a01 [2024/10/29 11:55] (aktuell) – vdemir | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== LU09.A01 - SQL- DCL: CREATE User ====== | + | ====== LU09.A01 - SQL- DCL: |
It is high time to mess a litte around with our new SQL powers, don't you think? So, let's try it directly on our Webstorm. | It is high time to mess a litte around with our new SQL powers, don't you think? So, let's try it directly on our Webstorm. | ||
Zeile 6: | Zeile 6: | ||
===== Requirements | ===== Requirements | ||
* Work type: individual | * Work type: individual | ||
- | * Timeframe: | + | * Timeframe: |
* Means of aid: | * Means of aid: | ||
* only teaching materials, no websearch, no use of ai. | * only teaching materials, no websearch, no use of ai. | ||
* Webstorm with connection to the MySQL-DB | * Webstorm with connection to the MySQL-DB | ||
- | * Expected result: | + | * Expected result: |
===== Case studies / Assignments ===== | ===== Case studies / Assignments ===== | ||
- | As a database administrators | + | Before |
- | To get the job done, follow the instructions below: | + | ==== Task 1.1 ==== |
- | + | ||
- | - Create as the sysdba (systemadministrator of the databaswe) a new user | + | |
- | - Grant this role only the necessary rights | + | |
- | - Create as a sysdba a test table and fill it with some testdata | + | |
- | - Establish a new connection within the webstorm by using the credentials of this new user | + | |
- | - Try out the DML operations, wich should be possible (insert, update, delete) | + | |
- | - Try out to DDL operations, which should result in errors due to missing permissions for that particular user | + | |
- | - Drop the newly created user finally | + | |
- | + | ||
- | + | ||
- | ==== Task A1: Prepatory Work ==== | + | |
**Login as root**: Login in from Webstorm to your database as //root// (sysdba = systemadministrator for the datababase) with your a // | **Login as root**: Login in from Webstorm to your database as //root// (sysdba = systemadministrator for the datababase) with your a // | ||
- | ==== Task A2: Preparatory Work ==== | + | ==== Task 1.2 ==== |
**New Database**: Create a new database named // | **New Database**: Create a new database named // | ||
CREATE DATABASE myDatabase; | CREATE DATABASE myDatabase; | ||
- | ==== Task A3: Preparatory Work ==== | + | ==== Task 1.3 ==== |
**use db**: Use that newly created db. | **use db**: Use that newly created db. | ||
USE myDatabase; | USE myDatabase; | ||
- | ==== Task A4: Preparatory Work ==== | + | ==== Task 1.4: ==== |
- | ** Create a test table**: Create a table //user// with 3 columns of your choice as a test table, and fill it with some test data. | + | ** Create a test table**: Create a table //users// with 3 columns of your choice as a test table. |
- | CREATE TABLE user ( | + | CREATE TABLE users ( |
user_id INT AUTO_INCREMENT PRIMARY KEY, | user_id INT AUTO_INCREMENT PRIMARY KEY, | ||
username VARCHAR(50) NOT NULL, | username VARCHAR(50) NOT NULL, | ||
Zeile 48: | Zeile 37: | ||
); | ); | ||
| | ||
- | INSERT INTO user (username, email) VALUES (' | + | ==== Task 1.5: ==== |
- | INSERT INTO user (username, email) VALUES (' | + | **Content data for testing:** Fill the table user with some test data: |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | + | ||
- | ==== Task B1 ==== | + | |
- | **Create the User**: Create a user named // | + | |
- | + | ||
- | CREATE USER ' | + | |
| | ||
- | + | INSERT INTO users (username, email) | |
- | ==== Task B2 ==== | + | |
- | ** Overview of the current privileges**: | + | |
- | + | (' | |
- | | + | ('sarah_johnson', 'sarah.johnson@example.com' |
- | + | | |
- | The result set should look like: | + | |
- | + | ('david_kim', 'david.kim@example.com' | |
- | {{: | + | ('laura_clark', ' |
- | + | | |
- | ==== Task B2 ==== | + | (' |
- | **Grant Privileges Without Table Management**: | + | |
- | + | ||
- | GRANT SELECT, INSERT, UPDATE, DELETE ON myAppDB.* TO 'restrictedUser'@'localhost'; | + | |
- | + | ||
- | ==== Task B3 ==== | + | |
- | **Rovoke Privileges**: | + | |
- | + | ||
- | REVOKE CREATE, ALTER, DROP ON myAppDB.* FROM 'restrictedUser'@'localhost'; | + | |
- | + | ||
- | ==== Tasc B4 ==== | + | |
- | **View the User’s Privileges**: | + | |
- | + | ||
- | SHOW GRANTS FOR 'restrictedUser' | + | |
- | + | ||
- | ==== Task B5 ==== | + | |
- | **Test the User’s Access**: Connect as // | + | |
- | + | ||
- | ==== Task B6 ==== | + | |
- | **Delete the User (optional)**: | + | |
===== Solution ===== | ===== Solution ===== |