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 dep_n1 (id serial primary key); CREATE TABLE post_1 (id serial primary key); CREATE TABLE emp_1 ( id serial, dep_id int, post_id int, date_work_begin date ); INSERT INTO emp_1 VALUES (9, null, null, '2021-01-01'), (10, null, null, '2020-01-01'), (11, null, null, '1990-01-01'); -- 1. Создать таблицы emp_2 и emp_3, используя данные из таблицы emp_1. CREATE TABLE emp_2 AS ( SELECT * FROM emp_1 ); CREATE TABLE emp_3 AS ( SELECT * FROM emp_1 ); -- 1.1. Установить первичный и внешние ключи. ALTER TABLE emp_2 ADD PRIMARY KEY(id); ALTER TABLE emp_3 ADD PRIMARY KEY(id); ALTER TABLE emp_2 ADD CONSTRAINT fk_dep_id FOREIGN KEY(dep_id) REFERENCES dep_n1(id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE emp_2 ADD CONSTRAINT fk_post_id FOREIGN KEY(post_id) REFERENCES post_1(id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE emp_3 ADD CONSTRAINT fk_dep_id FOREIGN KEY(dep_id) REFERENCES dep_n1(id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE emp_3 ADD CONSTRAINT fk_post_id FOREIGN KEY(post_id) REFERENCES post_1(id) ON DELETE CASCADE ON UPDATE CASCADE; -- 2. Из таблицы emp_2 удалить сотрудников, код которых заканчивается на на 0, а из таблицы emp_3 тех, -- кто был принят на работу до 1993 года. DELETE FROM emp_2 WHERE CAST(id AS text) LIKE '%0'; DELETE FROM emp_3 WHERE date_work_begin < '1993-01-01'; -- 3. Используя данные таблиц emp_1, emp_2, emp_3 и инструкции сочетания запросов вывести список удаленных в п.2 -- записей 2-мя вариантами построения запроса. SELECT * FROM emp_1 EXCEPT ( SELECT * FROM emp_2 INTERSECT SELECT * FROM emp_3 ); ( SELECT * FROM emp_1 EXCEPT SELECT * FROM emp_2 ) UNION ( SELECT * FROM emp_1 EXCEPT SELECT * FROM emp_3 );
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