added tasks 0 to 1

This commit is contained in:
Sven Vogel 2023-10-27 17:08:20 +02:00
parent b6d7709903
commit 03acb1a531
2 changed files with 53 additions and 0 deletions

29
tasks/01-select-intro.sql Normal file
View File

@ -0,0 +1,29 @@
-- Active: 1697184303960@@127.0.0.1@3306
# Date: 13.10.2023
# Author: Sven Vogel
# ---------------------------------------------
# setup database schema
CREATE SCHEMA IF NOT EXISTS task01;
USE task01;
# select a single number
SELECT 5 AS number;
# interpret value as hex
SELECT hex(255) AS hexnum;
# intger encode of ascii '5'
SELECT ASCII('5');
SELECT BIN(65);
# binary value of 'A'
SELECT BIN(ASCII('A'));
# binary encode of 'Mucke'
SELECT CONCAT_WS(
' ',
BIN(ASCII('M')),
BIN(ASCII('u')),
BIN(ASCII('c')),
BIN(ASCII('k')),
BIN(ASCII('e'))
);

24
tasks/02-create-table.sql Normal file
View File

@ -0,0 +1,24 @@
-- 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;