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 Tree ( id int, N int, P int ); INSERT INTO Tree VALUES (1, 1, 2), (2, 3, 2), (3, 6, 8), (4, 9, 8), (5, 2, 5), (6, 8, 5), (7, 5, null); SELECT * FROM Tree; select n node, case when p is null then 'Root' when n in (select p from tree) then 'Inner' else 'Leaf' end from tree order by n; create table json_index ( id varchar (100), N int, op_date timestamp, num real, str char(30), json_indexed jsonb, json_mas_indexed jsonb, json2_unindexed jsonb, json_mas_unindexed jsonb ); /* insert into json_index select main_part.*, to_json(json_rows.*), to_json(json_rows.*) from (select uuid_generate_v4() ,generate_series(1, 10) order_num , now() - (random() * (interval '90 days')) ,substr(md5(random()::text), 1, 30)) main_part inner join (select now() - (random() * (interval '90 days')) as json_datetime ,generate_series(1, 10) as json_order_number ,random()/random() as json_num ,uuid_generate_v4() json_uuid ,substr(md5(random()::text), 1, 60) json_str ) json_rows -- генерация случайных значений для JSON on main_part.order_num = json_rows.json_order_number ;*/ insert into json_index /* Альтернативный вариант select main_part.*, to_json(json_rows.*) json_obj, (select jsonb_agg(json_mas) from (SELECT generate_series(1, round(100*json_rows.json_num --добавляет случайности в массив *random()/random())::int) as json_mass_order_number --случайное количестов строк в массиве ,random()/random() as json_mas_num ,uuid_generate_v4() json_mas_uuid ,substr(md5(random()::text), 1, 60) json_mas_str) json_mas) json_mas from (select uuid_generate_v4() ,generate_series(1, 5) order_num -- задает количество строк в таблице , now() - (random() * (interval '90 days')) ,substr(md5(random()::text), 1, 30)) main_part inner join (SELECT now() - (random() * (interval '90 days')) as json_datetime ,generate_series(1, 5) as json_order_number -- генерирует строки JSON в таблицу ,random()/random() as json_num ,uuid_generate_v4() json_uuid ,substr(md5(random()::text), 1, 60) json_str) json_rows on main_part.order_num = json_rows.json_order_number;*/ select main_part.*, (select jsonb_agg(json_mas) from (SELECT generate_series(1, round(100*main_part.random_num/*добавляет случайности в массив JSON *//random())::int) as json_mass_order_number --случайное количестов строк в массиве ,random()/random() as json_mas_num ,uuid_generate_v4() json_mas_uuid ,substr(md5(random()::text), 1, 60) json_mas_str) json_mas) json_mas from (select uuid_generate_v4() ,generate_series(1, 10) order_num ,now() - (random() * (interval '90 days')) ,random()/random() as random_num ,substr(md5(random()::text), 1, 30)) main_part; select * from json_index
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
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