DEV Community

Moiz Ibrar
Moiz Ibrar

Posted on

Apache Age: AgeSQL cli Post-installation

To use AgeSQL, first, update the PATH variable to a PostgreSQL version compatible with Age:-

export PATH=/path/to/postgresql/12/bin:$PATH
Enter fullscreen mode Exit fullscreen mode

Then, create the database and set up the extension:

initdb agesqldb
Start the server
pg_ctl -D agesqldb -l logfile start
Create database
createdb agesqldb
Run it
./agesql agesqldb
Create extension of age in it and set the path

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

To create a graph, run the CREATE GRAPH command:

CREATE GRAPH network;
SET GRAPH = network;
SHOW GRAPH_PATH;
Enter fullscreen mode Exit fullscreen mode

You can directly run sql queries in it

SELECT * FROM users;
CREATE (:person {name: 'John'});
CREATE (:person {name: 'David'});
MATCH (p:person {name: 'John'}),(k:person{name: 'David'}) 
CREATE (p)-[e:KNOWS]->(k)
RETURN e;
MATCH (a)
OPTIONAL MATCH (a)-[e]->(b)
RETURN a, e, b;
Enter fullscreen mode Exit fullscreen mode

Apache-Age:-https://age.apache.org/
GitHub:-https://github.com/apache/age

Top comments (0)