Oracle Spatial and Graph – technical tips, best practices, and news from the product team

Property Graph Query Language (PGQL) support has been added to Oracle Database!

Alan Wu

Great news! Oracle just released a patch that adds Property Graph Query Language (PGQL) support to the existing property graph functions in Oracle Spatial and Graph in Oracle Database 12c Release 2 (

At a high level, PGQL is a SQL-like declarative language that allows a user to express a graph query pattern that consists of vertices and edges, and constraints on the properties of the vertices and edges.

Once this patch is applied to your database instance, you can run the following quick test, Groovy/Java based, to see how it works.

cd $ORACLE_HOME/md/property_graph/dal/groovy
$ sh ./gremlin-opg-rdbms.sh


opg-oracledb> // It is very likely that you need to customize
JdbcURL, Username, and Password in the following graph config

opg-oracledb> //
opg-oracledb> cfg =
.setName("connections") .setMaxNumConnections(8)
.setLoadEdgeLabel(false) .addVertexProperty("name",
PropertyType.STRING, "default_name")  .addEdgeProperty("cost",
PropertyType.DOUBLE, "1000000")  .build();

opg-oracledb> opg = OraclePropertyGraph.getInstance(cfg);

opg-oracledb> opg.clearRepository();     // start from


opg-oracledb> vfile="../../data/connections.opv"  //
vertex flat file

opg-oracledb> efile="../../data/connections.ope"  //
edge flat file

opg-oracledb> opgdl.loadData(opg, vfile, efile, 2,
10000, true, null);


opg-oracledb> opg.countVertices()
opg-oracledb> opg.countEdges()

opg-oracledb> // Create an in memory analytics session and

opg-oracledb> session=Pgx.createSession("session_ID_1");

opg-oracledb> analyst=session.createAnalyst();
opg-oracledb> // Read graph data from database into

opg-oracledb> pgxGraph =


opg-oracledb> pgxResultSet = pgxGraph.queryPgql("SELECT
n,m WHERE (n) -> (m)")


opg-oracledb> pgxResultSet.print(10);
| n                | m               |
| PgxVertex[ID=2]  | PgxVertex[ID=1] |
| PgxVertex[ID=3]  | PgxVertex[ID=1] |
| PgxVertex[ID=6]  | PgxVertex[ID=1] |
| PgxVertex[ID=7]  | PgxVertex[ID=1] |
| PgxVertex[ID=8]  | PgxVertex[ID=1] |
| PgxVertex[ID=9]  | PgxVertex[ID=1] |
| PgxVertex[ID=10] | PgxVertex[ID=1] |
| PgxVertex[ID=11] | PgxVertex[ID=1] |
| PgxVertex[ID=12] | PgxVertex[ID=1] |
| PgxVertex[ID=19] | PgxVertex[ID=1] |


[1] https://support.oracle.com/epmos/faces/PatchDetail?patchId=25640325


Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha

Integrated Cloud Applications & Platform Services