-- *** before: ***
-- a path of two steps was a chain of joins, and a path of unknown
-- length needed a recursive CTE
-- *** in version 2023: ***
CREATE PROPERTY GRAPH world_graph
VERTEX TABLES (country KEY (Code), city KEY (ID))
EDGE TABLES (
city AS located
SOURCE KEY (CountryCode) REFERENCES country (Code)
DESTINATION KEY (ID) REFERENCES city (ID)
);
SELECT * FROM GRAPH_TABLE (world_graph
MATCH (c IS country)-[e IS located]->(t IS city)
WHERE c.Continent = 'Europe'
COLUMNS (c.Name AS Country, t.Name AS City)
);
-- Support: Oracle 23ai is the only dialect here that reads SQL/PGQ.
-- PostgreSQL does graphs through the Apache AGE extension with a
-- different language; MySQL, SQLite, MS SQL Server (which has its own
-- MATCH syntax for graph tables since 2017), Firebird and Access do
-- not know the standard form.