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 the table CREATE TABLE orgchart( id INT PRIMARY KEY, name VARCHAR(20), role VARCHAR(20), manager_id INT, FOREIGN KEY (manager_id) REFERENCES orgchart(id)); # insert the rows INSERT INTO orgchart VALUES(1,'Matthew','CEO',NULL), (2,'Caroline','CFO',1),(3,'Tom','CTO',1), (4,'Sam','Treasurer',2),(5,'Ann','Controller',2), (6,'Anthony','Dev Director',3),(7,'Lousie','Sys Admin',3), (8,'Travis','Senior DBA',3),(9,'John','Developer',6), (10,'Jennifer','Developer',6),(11,'Maria','Junior DBA',8); # let's see the table, The CEO has no manager, so the manager_id is set to NULL SELECT * FROM orgchart; # find the reporting chain for all the employees WITH RECURSIVE reporting_chain(id, name, path) AS ( SELECT id, name, CAST(name AS CHAR(100)) FROM orgchart WHERE manager_id IS NULL UNION ALL SELECT oc.id, oc.name, CONCAT(rc.path,' -> ',oc.name) FROM reporting_chain rc JOIN orgchart oc ON rc.id=oc.manager_id) SELECT * FROM reporting_chain;
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