Final answer:
SQL queries are used to interact with databases, performing tasks such as selecting records, inserting new ones, updating existing data, or deleting records. The examples provided demonstrate basic CRUD operations.
Step-by-step explanation:
To write SQL queries that perform certain tasks in a database, you will need to define clear and precise statements adhering to the SQL syntax. Below are examples of SQL queries that could be used in the Zagi Retail Company sales department database to perform hypothetical tasks.
To retrieve all records from the sales table:
SELECT * FROM sales;To add a new sale record with information about the sale:
INSERT INTO sales (sale_id, product_id, quantity, sale_date) VALUES (1, 102, 3, '2023-04-01');To update the quantity sold for a specific sale:
UPDATE sales SET quantity = 4 WHERE sale_id = 1;To delete a sale record by its sale_id:
DELETE FROM sales WHERE sale_id = 1;
Each query is designed to perform a CRUD operation, which stands for Create, Read, Update, and Delete, and is essential for managing data within a database.