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
CREATE TABLE Peoples ( ID int primary key, NameAbbreviation varchar(255), Birthday timestamptz default now(), "Status" varchar(255) ); CREATE TABLE Phone ( PeopleID int, Phone int, "Comment" varchar(255) ); create unique index people_phone_idx ON Phone (PeopleID, Phone); -- ALTER TABLE Phone ADD CONSTRAINT "user_phone_ref" FOREIGN KEY (PeopleID) REFERENCES Peoples(ID); CREATE TABLE Address ( PeopleID int, Title varchar(255), "Comment" varchar(255) ); create unique index people_address_idx ON Address (PeopleID, Title); -- ALTER TABLE Address ADD CONSTRAINT "user_address_ref" FOREIGN KEY (PeopleID) REFERENCES Peoples(ID); CREATE TABLE General ( NameAbbreviation varchar(255), Birthday timestamptz default now(), "Status" varchar(255), Phone int, "Comment" varchar(255), City varchar(255), "Group" varchar(255) ); -- Общий список INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Иванов И. И.', '2.12.1990', 'женат', '126', 'интернет', 'Можга', 'Работа'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Иванов И. И.', '2.12.1990', 'женат', '127', 'старый', 'Можга', 'Работа'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Иванов И. И.', '9.18.2001', 'холост', '527', 'личный', 'Санкт-Петербург', 'Школа'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Петров П. П.', '4.23.1983', 'женат', '234', 'личный', 'Москва', 'Родня'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Петров П. П.', '4.24.1983', 'женат', '235', 'рабочий', 'Москва', 'Родня'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Васильев В. В.', '5.21.1998', 'холост', '456', 'личный', 'Белгород', 'Друзья'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Сидоров С.С.', '7.13.2007', 'холост', '643', 'личный', 'Киров', 'Родня'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Сидоров С.С.', '7.13.2007', 'холост', '654', 'старый', 'Киров', 'Родня'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Александров А.А.', '3.5.1987', 'женат', '412', 'рабочий', 'Уфа', 'Друзья'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Борисов Б.Б', '8.16.1989', 'холост', '723', 'рабочий', 'Москва', 'Работа'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Михайлов М.М.', '1.8.1997', 'женат', '876', 'личный', 'Сочи', 'Университет'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Михайлов М.М.', '1.8.1997', 'женат', '875', 'рабочий', 'Сочи', 'Университет'); INSERT INTO General (NameAbbreviation, Birthday, "Status", Phone, "Comment", City, "Group") VALUES ('Кириллов К.К.', '12.3.1996', 'холост', '933', 'личный', 'Киров', 'Работа'); -- Люди INSERT INTO Peoples (ID, NameAbbreviation, Birthday, "Status") VALUES (1, 'Иванов И. И.', '2.12.1990', 'женат'); INSERT INTO Peoples (ID, NameAbbreviation, Birthday, "Status") VALUES (2, 'Иванов И. И.', '9.18.2001', 'холост'); INSERT INTO Peoples (ID, NameAbbreviation, Birthday, "Status") VALUES (3, 'Петров П. П.', '4.23.1983', 'женат'); INSERT INTO Peoples (ID, NameAbbreviation, Birthday, "Status") VALUES (4, 'Васильев В. В.', '5.21.1998', 'холост'); INSERT INTO Peoples (ID, NameAbbreviation, Birthday, "Status") VALUES (5, 'Кузьмин К.К.', '5.21.2020', 'холост'); -- Телефоны INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (1, 123, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (1, 124, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (1, 125, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (1, 126, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (1, 127, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (2, 527, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (3, 234, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (4, 235, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (11, 456, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (12, 999, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (13, 997, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (14, 995, 'Личный'); INSERT INTO Phone (PeopleID, Phone, "Comment") VALUES (15, 993, 'Личный'); -- Адреса INSERT INTO Address (PeopleID, Title, "Comment") VALUES (1, 'Можга', 'Место рождения'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (1, 'Казань', 'По прописке'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (1, 'Москва', 'Рабочий'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (2, 'Санкт-Петербург', 'По прописке'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (3, 'Москва', 'По прописке'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (4, 'Белгород', 'По прописке'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (5, 'Уфа', 'По прописке'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (6, 'Сочи', 'По прописке'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (7, 'Киров', 'Рабочий'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (8, 'Владивосток', 'Место рождения'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (9, 'Рязань', 'Рабочий'); INSERT INTO Address (PeopleID, Title, "Comment") VALUES (10, 'Хабаровск', 'Место рождения'); -- Чему будет равна выборка: -- 1.SELECT ФИО, Д/р, Адрес FROM Общий список -- Решение: -- SELECT NameAbbreviation, Birthday, City FROM General; -- Решение: -- 2.SELECT ФИО, Статус FROM Общий список WHERE Адрес = «Можга» -- Решение: -- SELECT NameAbbreviation, "Status" FROM General WHERE City = 'Можга'; -- 3.SELECT ФИО FROM Общий список WHERE Адрес = «Москва» AND Группа = «Работа» -- Решение: -- SELECT NameAbbreviation FROM General WHERE City = 'Москва' AND "Group" = 'Работа'; -- 4.SELECT Д/р FROM Общий список WHERE Адрес = «Москва» OR Группа = «Работа» -- Решение: -- SELECT Birthday FROM General WHERE City = 'Москва' OR "Group" = 'Работа'; -- Что будет результатом следующих JOIN’ов: -- 1.INNER JOIN Люди, Адреса ON id = Чей адрес -- Решение: Inner join Peoples, Address ON id = PeopleID; -- Получить список всех таблиц со схемами -- SELECT * FROM INFORMATION_SCHEMA.TABLES;
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