SQLize
Online
/
PHPize Online
/
SQLtest Online
A
A
A
Share
Donate
Blog
Popular
Donate
A
A
A
Share
Blog
Popular
SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code.
You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.
SQL code:
Upload
Copy
Format
Clear
-- Aufgabe 1 CREATE TABLE Bahnstation ( Name VARCHAR(30) PRIMARY KEY, Barrierefrei BOOLEAN, Unterirdisch BOOLEAN, Toilette Integer, CONSTRAINT Keine_Negativen_Toiletten CHECK (Toilette IS NULL OR Toilette >= 0), CONSTRAINT Namenlänge CHECK (LENGTH(Name) > 2), CONSTRAINT Barrierefrei CHECK (Barrierefrei=1 OR Barrierefrei=0 OR Barrierefrei IS NULL), CONSTRAINT Unterirdisch CHECK (Unterirdisch=1 OR Unterirdisch=0 OR Unterirdisch IS NULL) ); CREATE TABLE Straßenbahn ( Linie INTEGER PRIMARY KEY, Farbe Varchar(10) UNIQUE NOT NULL, Strecke Varchar(255) NULL, CONSTRAINT Linie CHECK (Linie>0) ); CREATE TABLE Fahrzeug ( Fahrzeug CHAR(8) PRIMARY KEY, Linie INTEGER, FOREIGN KEY (Linie) REFERENCES Straßenbahn(Linie) ON DELETE SET NULL, CONSTRAINT Fahrzeug_format CHECK (Fahrzeug REGEXP '^FN-[A-Za-z0-9]{2}-[A-Za-z0-9]{2}$' AND NOT (Fahrzeug REGEXP 'Q' AND Fahrzeug REGEXP 'R')) ); CREATE TABLE Fahrplan ( Fahrzeug CHAR(8), Minute INTEGER, Richtung VARCHAR(30), Station VARCHAR(30), PRIMARY KEY (Fahrzeug, Minute), FOREIGN KEY (Richtung) REFERENCES Bahnstation(Name) ON DELETE CASCADE, FOREIGN KEY (Fahrzeug) REFERENCES Fahrzeug(Fahrzeug), FOREIGN KEY (Station) REFERENCES Bahnstation(Name) ); -- Aufgabe 2 SELECT * FROM Bahnstation WHERE Unterirdisch = 1 AND Toilette >= 2; -- Aufgabe 3 -- a -- b UPDATE Bahnstation SET Toilette = Toilette+2 WHERE Unterirdisch = 1; -- c ALTER TABLE Fahrzeug ADD Baujahr INTEGER(4); -- d ALTER TABLE Fahrzeug DROP COLUMN Baujahr; -- e ALTER TABLE Fahrplan ADD CONSTRAINT Echte_Minuten CHECK (Minute >= 0 AND Minute < 60); -- f ALTER TABLE Fahrplan DROP CONSTRAINT Station; DROP TABLE Bahnstation;
SQL
Server:
MariaDB 11.4
MariaDB 11.5
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 11
PostgreSQL 12
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
Version
ER Diagram
Preserve result
Stuck with a problem?
Got Error?
Ask ChatGPT!
Result:
Copy
Clear