DEV Community

Sadeed Ahmad
Sadeed Ahmad

Posted on

More on AGE with PostgreSQL

Initialization of Database

The database cluster is initialized


cd postgresql-11.18/
bin/initdb demo

Enter fullscreen mode Exit fullscreen mode

Kickstarting the server

Make a database named dbyo


bin/pg_ctl -D demo -l logfile start
bin/createdb dbyo

Enter fullscreen mode Exit fullscreen mode

The files and the database can now be seen in your terminal.

Start Querying

AGE has been added to pg. You can connect to the database and start exploring it.


bin/psql dbyo

Enter fullscreen mode Exit fullscreen mode

AGE extension is loaded in order to start using it.

CREATE EXTENSION age;
LOAD 'age';
SET search_path = ag_catalog, "$user", public;
Enter fullscreen mode Exit fullscreen mode

Queries with Cypher commands can be run like creating a graph, adding a node to it, and then displaying the node.

SELECT create_graph('demo_graph');
SELECT * FROM cypher('demo_graph', $$ CREATE (n:Person {name : "james", bornIn : "US"}) $$) AS (a agtype);
SELECT * FROM cypher('demo_graph', $$ MATCH (v) RETURN v $$) as (v agtype);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)