Files
2026-01-04 12:22:40 +03:00

34 lines
826 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
--Задача 1
CREATE TABLE products_extended (
id INT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
category VARCHAR(50),
price DECIMAL(6,2),
in_stock BOOLEAN DEFAULT true,
email_support VARCHAR
);
--Задача 2 Вариант с DEFAULT (in_stock не указываем)
INSERT INTO products_extended (id, name, category, price, email_support)
VALUES
(1, 'Mi Band 7', 'smartwatch', 49.00, 'miband@xiaomi.com'),
(2, 'Surface Pro', 'tablet', 1299.00, 'surface@microsoft.com');
--Задача 3
ALTER TABLE products_extended
ADD COLUMN rating DECIMAL(3,2),
DROP COLUMN email_support;
--Задача 4
UPDATE products_extended
SET price = price * 1.1
WHERE name = 'Mi Band 7';
--Задача 5(удаляет данные/таблицу)
TRUNCATE TABLE products_extended;
DROP TABLE products_extended;