Professional Documents
Culture Documents
Lab3 ICT Zhamilya
Lab3 ICT Zhamilya
Task 1
DDL (Data Definition Language) is a subset of SQL (Structured Query Language)
used to define the structure of a database and its objects such as tables, views,
indexes, and procedures. DDL Statements are used to create, modify, and delete
database objects, including tables, views, indexes, and stored procedures. Some of
the most common DDL operators include:
4. TRUNCATE: This statement is used to delete all rows in a table, but unlike
the DROP statement, it preserves the table structure and indexes.
4. DELETE: This statement is used to delete data from a table. For example,
the following SQL statement deletes the customer with id 1 from the table
"customers":
DELETE FROM customers WHERE id = 1;
DML Statements are executed immediately and can be undone with a rollback
statement.
Task 2
SELECT product_id
FROM order_items
JOIN products ON order_items.product_id = products.id;
SELECT order_code
FROM order_items
JOIN orders ON order_items.order_code = orders.code;
SELECT customer_id
FROM orders
JOIN customers ON orders.customer_id = customers.id;
Task 3
Task 4
UPDATE products
SET name = 'Stray Kids 5-STAR album A version'
WHERE name = 'Stray Kids Maxident album';
UPDATE products
SET price = 2500
WHERE price = 2900;
DELETE FROM products WHERE name = 'Stray Kids 5-STAR album C version';
DELETE FROM products WHERE name = 'Bangchan Levanter card';