added tasks from 27.10.2023

This commit is contained in:
Sven Vogel 2023-10-27 19:06:52 +02:00
parent 03acb1a531
commit 11d76cae66
4 changed files with 77 additions and 0 deletions

6
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,21 @@
CREATE SCHEMA task03;
USE task03;
CREATE TABLE Colors (
colorName SET ('red', 'green', 'blue')
);
/* can have multiple values at once and be empty */
INSERT INTO Colors VALUES ('red');
INSERT INTO Colors VALUES ('green');
INSERT INTO Colors VALUES ('blue,green');
INSERT INTO Colors VALUES ('');
CREATE TABLE Animals (
name ENUM ('Dog', 'Cat', 'Bird')
);
/* cannot be empty or multiple variants at once */
INSERT INTO Animals VALUES ('Dog');
INSERT INTO Animals VALUES ('Cat');
INSERT INTO Animals VALUES ('Bird');

21
tasks/05-create-table.sql Normal file
View File

@ -0,0 +1,21 @@
CREATE SCHEMA employees;
DROP TABLE IF EXISTS employees.Employee;
CREATE TABLE employees.Employee (
id BINARY(16) PRIMARY KEY, /* automatically NOT NULL */
name NVARCHAR(64) NOT NULL, /* this field is mandatory */
email VARCHAR(32) /* optional field */
);
INSERT INTO employees.Employee SET
id = UUID_TO_BIN(UUID()),
name = 'Hans Jürgen Peter';
INSERT INTO employees.Employee VALUES (
id = UUID_TO_BIN(UUID()),
name = 'Guten Tag',
email = 'klaus@doof.de'
);
SELECT hex(id), name, email FROM employees.Employee;

29
tasks/task-6-1-1.sql Normal file
View File

@ -0,0 +1,29 @@
CREATE SCHEMA cities;
CREATE TABLE cities.Cities (
id BINARY(16) NOT NULL, /* UUID */
name NVARCHAR(32) NOT NULL,
countryName CHAR(2) CHARACTER SET ASCII NOT NULL, /* country code such DE, US, CH, ... */
countryCode NUMERIC(3) NOT NULL, /* numeric country code */
url VARCHAR(100),
history MEDIUMTEXT,
icon BLOB
);
INSERT INTO cities.Cities SET
id = UUID_TO_BIN(UUID()),
name = 'Berlin',
countryName = 'DE',
countryCode = 268,
url = 'https://www.berlin.de/en/',
history = 'German Empire, 3rd Reich, split into two, reunited :)';
INSERT INTO cities.Cities SET
id = UUID_TO_BIN(UUID()),
name = 'Berlin',
countryName = 'US',
countryCode = 840,
url = 'https://www.berlinnh.gov/',
history = 'some weird country. They like guns';
SELECT name, countryName, countryCode, url, history FROM cities.Cities ORDER BY countryName;