UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • GQL vs Other Languages
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Questioned Paths
    • Shortest Paths
    • Cheapest Paths
    • K-Hop Traversal
    • Graph Patterns
    • Overview
    • Open Graphs
    • Closed Graphs
    • Graphs with Edge ID
    • Graph Types
    • Constraints
    • Projections
    • Storage Maintenance
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • MERGE
    • SET
    • REMOVE
    • DELETE
    • FOREACH
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Element Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Null Functions
    • Utility Functions
    • Type Conversion Functions
    • Table Functions
    • Database Functions
  • Operators
  • Predicates
    • CASE
    • LET Value Expression
    • Value Query Expression
    • List Expressions
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
  • Query Management
  • Execution Plan
  • Backup and Restore
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Naming Conventions
    • Syntactic Notation
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Graph Management

Overview

An Ultipa instance can host multiple graphs, each representing a dataset of interconnected nodes and edges.

Showing Graphs

Show graphs in the database:

GQL
SHOW GRAPHS

To inspect a single graph:

GQL
DESCRIBE GRAPH myGraph

-- DESC is a shorthand for DESCRIBE
DESC GRAPH myGraph

Each graph provides the following metadata:

Field
Description
graph_idThe ID of the graph.
graph_nameThe unique name of the graph.
currentWhether the graph is the current graph.
graph_typeThe type of the graph (OPEN or CLOSED).
node_countThe number of nodes in the graph.
edge_countThe number of edges in the graph.
node_label_countThe number of node labels in the graph.
edge_label_countThe number of edge labels in the graph.
procedure_countThe number of stored procedures in the graph.
fulltext_index_countThe number of full-text indexes in the graph.
trigger_countThe number of triggers in the graph.
created_atThe creation time of the graph.
commentThe comment of the graph.

Selecting Current Graph

Most GQL queries operate on a specific graph. Use the USE statement to set the current graph:

GQL
USE myGraph

-- USE is a shorthand for USE GRAPH
USE GRAPH myGraph

All subsequent queries in the session will run against myGraph until another USE is issued.

Creating Graphs

Ultipa supports two main types of graphs: Open Graph and Closed Graph. This design offers both flexibility and control, supporting workflows ranging from agile exploration to production-grade applications demanding strict data integrity requirements.

Open Graphs

Open graphs are schema-free, requiring no explicit schema definitions before data insertion. You can directly insert nodes and edges, and their labels and properties are created on the fly. This offers maximum flexibility for early-stage data exploration.

Learn more about open graphs →

Closed Graphs

Closed graphs require that any node or edge to be inserted must conform to a defined node or edge type. This ensures consistent structure, guaranteeing high data integrity and consistency.

Learn more about closed graphs →

Graphs with Edge ID Support

By default, edges receive a system-generated _id and custom values cannot be assigned. The optional EDGE_ID feature lets edges carry a user-facing _id. Enable it at creation with WITH EDGE_ID:

GQL
CREATE GRAPH myGraph WITH EDGE_ID

EDGE_ID can also be toggled on an existing graph.

Learn more about graphs with edge ID support →

Ontology Graphs

Ontology support enables RDF/OWL-style class hierarchies and the @prefix:name label syntax. Create an ontology-enabled graph with WITH ONTOLOGY:

GQL
CREATE GRAPH myOntologyGraph WITH ONTOLOGY

For details on ontology features, see Ontology.

Using IF NOT EXISTS

You can use the IF NOT EXISTS clause to prevent errors when attempting to create a graph that already exists. It allows the statement to be safely executed.

GQL
CREATE GRAPH IF NOT EXISTS myGraph

This creates the graph myGraph only if a graph with that name does not exist. If myGraph already exists, the statement is ignored without throwing an error.

Cloning Graphs

A new graph can be created from an existing one, cloning both data and schema (if it's a closed graph):

GQL
CREATE GRAPH newGraph AS COPY OF myGraph

Converting Between Open and Closed

A closed graph can be converted to an open graph, and vice versa.

Convert a closed graph to open. Existing type definitions are preserved but no longer enforced:

GQL
ALTER GRAPH myGraph SET OPEN

Convert an open graph to closed:

GQL
ALTER GRAPH myGraph SET CLOSED

After conversion, the graph has no node/edge types defined. You must add node and edge types before inserting new data. Existing data is not validated against the new types, only future inserts are checked.

Renaming Graphs

Rename myGraph to newGraph:

GQL
ALTER GRAPH myGraph RENAME TO newGraph

Commenting Graphs

Set comment for myGraph:

GQL
ALTER GRAPH myGraph COMMENT "This is a description"

Dropping Graphs

Drop the graph myGraph:

GQL
DROP GRAPH myGraph

The IF EXISTS clause is used to prevent errors when attempting to delete a graph that does not exist. It allows the statement to be safely executed.

GQL
DROP GRAPH IF EXISTS myGraph

This deletes the graph myGraph only if a graph with that name does exist. If myGraph does not exist, the statement is ignored without throwing an error.

Truncating Graphs

The truncating operation deletes all nodes, edges, and index data from the graph while preserving the graph itself. For closed graphs, the graph type is preserved.

You may truncate the entire graph, all nodes or edges, or nodes or edges with a specific label (open graph) or type (closed graph). Note that truncating nodes will also remove any edges connected to them.

GQL
-- Truncate the entire graph
TRUNCATE GRAPH myGraph

-- Truncate all nodes in myGraph, all edges will also be removed
TRUNCATE NODE * ON myGraph

-- Truncate User nodes in myGraph, edges connected to them will also be removed
TRUNCATE NODE User ON myGraph

-- Truncate all edges in myGraph
TRUNCATE EDGE * ON myGraph

-- Truncate Follows edges in myGraph
TRUNCATE EDGE Follows ON myGraph