Create a Property Graph from Scratch

You can create graphs from scratch by using the PGQL CREATE PROPERTY GRAPH statement in the Query Playground page.

To create a graph from scratch:
  1. Select Graphs from the main navigation menu and navigate to the Graphs page.
  2. Click </> Query in the Property Graph tab and navigate to the Query Playground page.
  3. Enter the PGQL CREATE PROPERTY GRAPH statement to create a property graph.

    The following code examples describe the creation of PGQL and SQL property graphs respectively.

    • Creating a PGQL Property Graph
      CREATE PROPERTY GRAPH BANK_GRAPH
        VERTEX TABLES (
          bank_accounts
            KEY ( id )
            LABEL Accounts PROPERTIES ( id, name )
        )
        EDGE TABLES (
          bank_txns
            SOURCE KEY ( from_acct_id ) REFERENCES bank_accounts (id)
            DESTINATION KEY ( to_acct_id ) REFERENCES bank_accounts (id)
            LABEL transfers PROPERTIES ( amount, description, from_acct_id, to_acct_id, txn_id )
        )OPTIONS (PG_PGQL)
    • Creating a SQL Property Graph:

      SQL property graphs are supported only in Oracle AI Database 26ai. Therefore, if you are using an Autonomous AI Database instance with Oracle AI Database 26ai, then you have the option to create SQL property graphs.

      CREATE PROPERTY GRAPH BANK_GRAPH
        VERTEX TABLES (
          bank_accounts
            KEY ( id )
            LABEL Accounts PROPERTIES ( id, name )
        )
        EDGE TABLES (
          bank_txns
            SOURCE KEY ( from_acct_id ) REFERENCES bank_accounts (id)
            DESTINATION KEY ( to_acct_id ) REFERENCES bank_accounts (id)
            LABEL transfers PROPERTIES ( amount, description, from_acct_id, to_acct_id, txn_id )
        )OPTIONS (PG_SQL)
  4. Click Run to create the desired property graph.