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:loesungen:l02 [2024/09/27 13:44] – vdemir | modul:m290:learningunits:lu06:loesungen:l02 [2024/11/13 16:43] (aktuell) – cbolzern | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ====== | + | ====== |
| - | ===== Case studies / Assignments | + | ===== Task 2.1 ===== |
| + | **Create the User**: Create a user named // | ||
| - | ==== Task A: CREATE | + | |
| - | Create a table called employees with the following columns: | + | |
| - | * employee_id (INT) as the primary key | + | ===== Task 2.2 ===== |
| - | * first_name (VARCHAR 50) | + | ** Overview of the current privileges**: Display all users. |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | employee_id INT PRIMARY KEY, | + | |
| - | first_name VARCHAR(50), | + | |
| - | last_name VARCHAR(50), | + | |
| - | hire_date DATE, | + | |
| - | salary DECIMAL(10, | + | |
| - | ); | + | |
| + | The result set should look like: | ||
| - | ==== Task B: CREATE TABLE ==== | + | {{:modul:m290: |
| - | Create a table called products to store inventory information. The table should have: | + | |
| - | * product_id (INT) as an auto-incrementing primary key | + | ===== Task 2.3 ===== |
| - | * product_name (VARCHAR 100) | + | **Grant Privileges Without Table Management**: Grant the user // |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | product_id INT AUTO_INCREMENT PRIMARY KEY, | + | |
| - | product_name VARCHAR(100), | + | |
| - | category VARCHAR(50), | + | |
| - | price DECIMAL(10, | + | |
| - | stock_quantity INT | + | |
| - | ); | + | |
| + | ===== Task 2.4 ===== | ||
| + | **Revoke Privileges**: | ||
| - | ==== Task C: ALTER TABLE ==== | + | REVOKE CREATE, |
| - | Add a new column email (VARCHAR 100) to the employees table. | + | |
| - | ALTER TABLE employees | + | ===== Tasc 2.5 ===== |
| - | ADD COLUMN email VARCHAR(100); | + | **View the User’s Privileges**: |
| - | ==== TASK D: MODIFY COLUMN ==== | + | SHOW GRANTS FOR 'restrictedUser' |
| - | Change the salary column's data type to FLOAT in the employees table. | + | |
| + | {{: | ||
| - | ALTER TABLE employees | + | ===== Task 2.6 ===== |
| - | | + | **Test the User’s Access**: Establish a new console connection to the database by using // |
| - | ==== TASK E: DROP COLUMN ==== | + | {{:modul: |
| - | Remove the stock_quantity column from the products table. | + | |
| - | ALTER TABLE products | + | ===== Task 2.7 ==== |
| - | DROP COLUMN stock_quantity; | + | |
| + | Finally, try to perform a CREATE TABLE or DROP TABLE operation. The attempt should result in a permission error als displayed in the image below. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | ===== Task 2.8 ===== | ||
| + | **Delete the User (optional)**: | ||
| + | |||
| + | {{: | ||
| - | ==== TASK F: DROP TABLE ==== | ||
| - | Completely remove the products table from the database. | ||
| - | DROP TABLE products; | ||
| ===== Vocabulary ===== | ===== Vocabulary ===== | ||
| ^ English ^ German ^ | ^ English ^ German ^ | ||
| - | | ... | ... | | + | | .. | .. | |
| - | | ... | ... | | + | |
| ---- | ---- | ||
| [[https:// | [[https:// | ||