Data manipulation statements (DML)
Data manipulation statements read and change the rows stored in tables. In CoraDB they work on relational tables and on the vertex and edge tables of a graph alike; graph data can also be queried with MATCH patterns inside a SELECT.
All examples in this section use the e-commerce sample database.
Reading data
Section titled “Reading data”| Statement | What it does |
|---|---|
| SELECT | Returns rows from tables, views, subqueries and graph patterns. |
| WITH (CTE) | Names intermediate results for one statement; WITH RECURSIVE builds rows step by step. |
| Hierarchical queries | Walks tree-structured data with START WITH ... CONNECT BY. |
Changing data
Section titled “Changing data”| Statement | What it does |
|---|---|
| INSERT | Adds rows from values or a query; ON DUPLICATE KEY UPDATE turns a conflicting insert into an update. INSERT VERTEX and INSERT EDGE add graph data. |
| UPDATE | Changes column values in one table or, through a join, in several tables. |
| REPLACE | Inserts rows, first deleting any existing row with the same primary key or unique value. |
| DELETE | Removes the rows that match a condition, from one or several tables. |
| MERGE | Updates, deletes or inserts target rows depending on whether they match a source. |
| TRUNCATE | Removes every row of a table and resets its AUTO_INCREMENT counter. |
Other statements
Section titled “Other statements”| Statement | What it does |
|---|---|
| PREPARE, EXECUTE, DEALLOCATE | Compiles a statement once and runs it with different parameter values. |
| DO | Evaluates an expression without returning a result. |
Changes made by these statements become permanent when the transaction commits. See Transactions for commit, rollback and isolation levels.