MySQL/tasks/02-create-table.sql

24 lines
782 B
MySQL
Raw Normal View History

2023-10-27 15:08:20 +00:00
-- Active: 1697184303960@@127.0.0.1@3306
CREATE SCHEMA IF NOT EXISTS task02;
USE task02;
DROP TABLE IF EXISTS fruits;
CREATE TABLE fruits (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(45) NOT NULL,
color VARCHAR(10)
);
INSERT INTO fruits (name, color) VALUES ('Banane', 'gelb');
INSERT INTO fruits (name, color) VALUES ('Kiwi', 'grün');
INSERT INTO fruits (name, color) VALUES ('Apfel', 'grün');
INSERT INTO fruits (name, color) VALUES ('Apfel', 'rot');
INSERT INTO fruits (name, color) VALUES ('Erdbeere', 'rot');
INSERT INTO fruits (name, color) VALUES ('Himbeere', 'rot');
INSERT INTO fruits (name, color) VALUES ('Birne', 'grun');
SELECT * FROM fruits;
SELECT name FROM fruits WHERE color = 'rot';
SELECT name FROM fruits;
SELECT DISTINCT name FROM fruits;