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 Graph
    • Closed Graph
    • Graph Type
    • Constraints
    • 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
    • AI & Vector Functions
    • Database Functions
  • Operators
  • Predicates
    • CASE
    • LET Value Expression
    • Value Query Expression
    • List Comprehension
    • 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. Data Manipulation

INSERT OVERWRITE

Overview

The INSERT OVERWRITE statement allows you to overwrite existing nodes in the graph. If no existing node with the same _id is found, it inserts a new node instead.

The overwrite operation works by deleting the existing node with the same _id first, then inserting the new node. This means all properties and labels of the existing node are replaced with the new definition.

To merge new properties into an existing entity instead of replacing it, use UPSERT.

Overwriting Nodes

An existing node will be overwritten if _id is included in the property specification and a node with that _id exists in the graph:

GQL
INSERT OVERWRITE (:User {_id: "U2", name: "Jumpy88"})

If a node with _id equal to U2 already exists, it will be deleted and replaced with the new node. If no such node exists, a new node will be inserted.

If _id is not specified, a new node is always inserted:

GQL
INSERT OVERWRITE (:User {name: "Jumpy88"})

Since the property specification does not include _id, a new node will be inserted with a system-generated _id.