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:a02 [2024/10/28 14:35] – vdemir | modul:m290:learningunits:lu06:aufgaben:a02 [2024/11/20 14:36] (aktuell) – cbolzern | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== LU09.A02 - SQL- DCL: CREATE | + | ====== LU09.A02 - SQL- DCL: CREATE |
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. | ||
Zeile 25: | Zeile 25: | ||
- Drop the newly created user finally | - Drop the newly created user finally | ||
+ | ==== Task 2.1 ==== | ||
+ | **Create the User**: Create a user named // | ||
- | ==== Task A1: Prepatory Work ==== | + | CREATE USER ' |
- | **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 2.2 ==== |
- | **New Database**: Create a new database named // | + | |
- | + | ||
- | CREATE DATABASE myDatabase; | + | |
- | + | ||
- | ==== Task A3: Preparatory Work ==== | + | |
- | **use db**: Use that newly created db. | + | |
- | + | ||
- | USE myDatabase; | + | |
- | + | ||
- | ==== Task A4: Preparatory Work ==== | + | |
- | ** 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 TABLE user ( | + | |
- | user_id INT AUTO_INCREMENT PRIMARY KEY, | + | |
- | username VARCHAR(50) NOT NULL, | + | |
- | email VARCHAR(100) NOT NULL | + | |
- | ); | + | |
- | + | ||
- | 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 (' | + | |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | INSERT INTO user (username, email) VALUES (' | + | |
- | + | ||
- | ==== Task B1 ==== | + | |
- | **Create the User**: Create a user named // | + | |
- | + | ||
- | CREATE USER ' | + | |
- | + | ||
- | + | ||
- | ==== Task B2 ==== | + | |
** Overview of the current privileges**: | ** Overview of the current privileges**: | ||
Zeile 72: | Zeile 37: | ||
The result set should look like: | The result set should look like: | ||
- | {{: | + | ==== Task 2.3 ==== |
- | + | ||
- | ==== Task B2 ==== | + | |
**Grant Privileges Without Table Management**: | **Grant Privileges Without Table Management**: | ||
- | GRANT SELECT, INSERT, UPDATE, DELETE ON myAppDB.* TO ' | + | GRANT SELECT, INSERT, UPDATE, DELETE ON myDatabase.* TO ' |
- | ==== Task B3 ==== | + | ==== Task 2.4 ==== |
- | **Rovoke | + | **Revoke |
- | REVOKE CREATE, ALTER, DROP ON myAppDB.* FROM ' | + | REVOKE CREATE, ALTER, DROP ON myDatabase.* FROM ' |
- | ==== Tasc B4 ==== | + | ==== Tasc 2.5 ==== |
**View the User’s Privileges**: | **View the User’s Privileges**: | ||
SHOW GRANTS FOR ' | SHOW GRANTS FOR ' | ||
+ | | ||
+ | ==== Task 2.6 ==== | ||
+ | **Test the User’s Access**: Establish a new console connection to the database by using // | ||
+ | |||
+ | ==== Task 2.7 ==== | ||
- | ==== Task B5 ==== | + | Finally, |
- | **Test the User’s Access**: Connect as // | + | |
- | ==== Task B6 ==== | + | ==== Task 2.8 ==== |
- | **Delete the User (optional)**: | + | **Delete the User (optional)**: |
===== Solution ===== | ===== Solution ===== | ||
- | [[modul: | + | [[modul: |