Types
SQL - CREATE TYPE
Creates a new type in the schema.
Syntax
CREATE <DOCUMENT|VERTEX|EDGE> TYPE <type>
[UNIDIRECTIONAL] [LIGHTWEIGHT] [UNIQUE] [ IF NOT EXISTS ]
[EXTENDS <super-type>] [BUCKET <bucket-id>[,]*] [BUCKETS <total-bucket-number>] [PAGESIZE <page-size>]
[CUSTOM <custom-key> = <custom-value>[,]*]
-
Use
<DOCUMENT|VERTEX|EDGE>if you are creating respectively a document, vertex or edge type. -
<type>Defines the name of the type you want to create. You must use a letter, underscore or dollar for the first character, for all other characters you can use alphanumeric characters, underscores and dollar. -
UNIDIRECTIONAL Defines an edge types (only) to be of single direction instead of the default bi-directional edge. An edge of such a type is written on its source vertex only, which halves the write cost of the edge list, but the target vertex keeps no trace of it: walking the vertex API from the target (
vertex.getVertices(IN, …), Gremlin’sin()) finds nothing, and so do the SQL functionsin(),inE(),both(),bothE()andshortestPath()called on their own (SELECT in('E') FROM …), which read what the vertex stores, as the vertex API does embedded, remote and through Gremlin. A pattern is answered whichever way it is written: Cypher and SQLMATCHstart the walk from the source side whenever the pattern allows it, and a walk that has to start from the target (the target is bound by an earlier clause, the hop is undirected, a pattern expression such asCOUNT { (t)←[:E]-() }, a CyphershortestPath()) is answered by scanning the edges of the type once per query. That scan is held in heap and counts againstarcadedb.queryMaxHeapElementsAllowedPerOpandarcadedb.queryMaxHeapRAM, so declare an edge type unidirectional only when its edges are queried from their source: a workload that looks up the incoming side often (many small queries by target, or a loop that commits between a write and a read) pays that scan every time, and is better served by a bidirectional type.Graph algorithms and path procedures ask about the graph rather than about what a vertex stores, so they always answer the incoming side of a unidirectional edge type, the same as with a Graph Analytical View: the Cypher
algo.*procedures, thepath.*procedures (path.expand,path.expandConfig,path.spanningTree,path.subgraphNodes,path.subgraphAll), the SQL functionsdijkstra(),astar(),bellmanFord(),cchShortestPath()andduanSSSP(), and the functionsnode.degree,node.degree.in,node.relationship.existsandnode.relationship.types. Analgo.*procedure that loads the whole graph derives the incoming side from the outgoing lists of the vertices it loaded, with no scan. A walk that goes vertex by vertex (thepath.*procedures, the SQL path-finding functions, thenode.*functions) builds one in-heap index per unidirectional type the first time it needs it, the scan described above, bounded byarcadedb.queryMaxHeapElementsAllowedPerOp.refactor.mergeNodes,refactor.cloneNodesWithRelationshipsand adding or removing a node’s labels in Cypher (which moves the vertex to another type) carry the incoming unidirectional edges of the node over too, instead of dropping them. The SQL functionsin(),inE(),both(),bothE()andshortestPath()called on their own keep reading what the vertex stores, as before.Since 26.10.2 the graph algorithms, path procedures and path-finding functions listed above answer both sides of a unidirectional edge, and
refactor.mergeNodes,refactor.cloneNodesWithRelationshipsand a Cypher label change keep the incoming unidirectional edges of the node. -
LIGHTWEIGHT Defines an edge type (only) whose edges are stored inside the two vertices they connect, with no edge record and therefore no properties. Orthogonal to
UNIDIRECTIONAL. See Lightweight Edges. -
UNIQUE Defines an edge type (only) that allows at most one edge per ordered
(out, in)pair of vertices. On a regular edge type this creates a unique index on(@out, @in); on aLIGHTWEIGHTtype there are no records to index and the check scans the source vertex’s edge list instead. See Lightweight Edges. -
IF NOT EXISTS Specifying this option, the type creation will just be ignored if the type already exists (instead of failing with an error)
-
<super-type>Defines the super-type you want to extend with this type. It must be a document type or a type of the same kind as the new one:CREATE VERTEX TYPE … EXTENDStakes a vertex or a document type,CREATE EDGE TYPE … EXTENDSan edge or a document type, andCREATE DOCUMENT TYPE … EXTENDSonly a document type. Any other super-type refuses the statement before the type is created. (Since v26.12.1, issue #12029. Before, for example, a document or an edge type could extend a vertex type, and openCypher then failed withClassCastExceptionon the first such record a label scan met.) -
<bucket-id>Defines in a comma-separated list the ID’s of the buckets you want this type to use. A bucket given by its ID must exist already, and an unknown ID refuses the statement; a bucket given by its name is created when it does not exist. (Since v26.12.1, issue #12436. Before, a bucket given by its ID failed the statement with aNullPointerException.) -
<total-bucket-number>Defines the total number of buckets you want to create for this type. When omitted, the default is taken from thearcadedb.typeDefaultBucketsglobal configuration setting (TYPE_DEFAULT_BUCKETS), which is1by default. -
<page-size>Defines the page size of the type. -
<custom-key>Name of a custom property to set on the new type. Multiple pairs can be listed, separated by commas. -
<custom-value>Value for the custom property. All data types are supported as values.
In the event that a bucket of the same name exists in the bucket, the new type uses this bucket by default. If you do not define a bucket in the command and a bucket of this name does not exist, ArcadeDB creates one. The new bucket has the same name as the type, but in lower-case.
A bucket belongs to one type only. The statement is refused when a bucket it would attach already belongs to another type, whether
listed in BUCKET or reused because its name is <type>_<n>, and when the same bucket is listed twice. The refusal is checked
before anything is created, so the schema is left as it was and no half-built type remains. (Since v26.11.1. Before, the type was
registered first and stayed in the schema, without the refused bucket, and also after a restart.)
A type also keeps some buckets for its own use: the paired ext bucket of its EXTERNAL properties, the _out_edges and
_in_edges buckets of each of its vertex buckets, and the buckets of its super-node stripe pool. Another type cannot take
such a bucket as one of its own: the statement is refused with an error that names the type the bucket belongs to. A vertex
type is also refused a bucket whose _out_edges or _in_edges bucket already belongs to another type. _(Since v26.12.1.)
When working with multiple cores, it is recommended that you use multiple buckets to improve concurrency during inserts. To change
the number of buckets created by default, ALTER DATABASE command to update the minimumbuckets property.
You can also define the number of buckets you want to create using the BUCKETS option when you create the type.
Examples
-
Create the document type
Account:
ArcadeDB> CREATE DOCUMENT TYPE Account
-
Create the vertex type
Carto extendVehicle:
ArcadeDB> CREATE VERTEX TYPE Car EXTENDS Vehicle
-
Create the vertex type
Car, using the bucket with name 'Car_classic' and 'Car_modern':
ArcadeDB> CREATE VERTEX TYPE Car BUCKET Car_classic,Car_modern
-
Create the document type
Accountwith the custom property 'description':
ArcadeDB> CREATE DOCUMENT TYPE Account CUSTOM description = 'All users'
-
Create the vertex type
Carwith multiple custom properties:
ArcadeDB> CREATE VERTEX TYPE Car CUSTOM icon = 'car.png', owner = 'fleet-team'
Declaring CUSTOM inline is equivalent to running ALTER TYPE … CUSTOM right after the creation, but it happens in the same statement.
When IF NOT EXISTS is used and the type is already there, the whole statement is skipped, so the custom properties are not applied to the existing type.
|
|
The same applies to Before that version, |
A type inherits the bucket selection strategy defined at the database level (round-robin by default).
For the full list of supported strategies, the decision tree for picking one, and the WITH repartition = true workflow for changing strategy on a populated type, see Bucket Selection Strategies in the Schema concepts section and Bucket Selection Strategy for the animated walkthrough.
For more information, see:
SQL - ALTER TYPE
Change a type defined in the schema. The change is persistent.
Syntax
ALTER TYPE <type> <change> [, <change> ]*
Where each <change> is either <attribute-name> <attribute-value> or CUSTOM <custom-key> = <custom-value>.
-
<type>Defines the type you want to change. -
<attribute-name>Defines the attribute you want to change. For a list of supported attributes, see the table below. -
<attribute-value>Defines the value you want to set. -
<custom-key>Name of the custom property to set. -
<custom-value>Value for the custom property. All data types are supported as values.
A custom property can be deleted by setting its value to null.
|
|
Several changes can be applied in one statement, separated by commas, and they are applied in the order written:
Before that version the comma-separated form parsed and answered |
Examples
-
Add
Personto the super types:
ArcadeDB> ALTER TYPE Employee SUPERTYPE +Person
-
Remove a super-type:
ArcadeDB> ALTER TYPE Employee SUPERTYPE -Person
|
Removing a super-type also removes the indexes the type inherited from it. Those indexes were created when the
super-type was assigned, they cover a property the type no longer has, and the super-type’s |
Assigning a super-type is refused, before anything changes, when it would close a cycle (the super-type is the type
itself or already one of its sub types, at any depth), or when it is a type of another kind: a vertex type can extend a vertex
or a document type, an edge type an edge or a document type, and a document type only a document type. The same applies to the
Java API (addSuperType()) and to the JSONL import of a logical export, which links the exported super-types the same way.
(Since v26.12.1, issues #12028 and #12029. Before, a cycle failed with a StackOverflowError (HTTP 500) but stayed in the
schema, after which queries on the type failed and the database could not be reopened; a link to a type of another kind was
accepted, and openCypher then failed with ClassCastException.) A database whose schema already holds a cycle still opens:
one link of the cycle is left out, with a warning in the log naming it, and the next schema save writes the result. Which link
is left out depends on the order the types are loaded in. A link between types of different kinds written by an earlier
version is kept.
|
Assigning a super-type with a UNIQUE index is refused with a DuplicatedKeyException when a record of the type
holds a key the index already holds (or two records of the type share one), and the type is left as it was. The same
applies to ALTER TYPE … BUCKET + when the bucket added already holds records: a duplicate key refuses the statement
and the bucket is not attached. (Since v26.12.1, issue #11302. Before, the statement was accepted and the type’s part
of the index was left empty, so queries using that index missed the type’s records.)
|
Assigning a super-type builds its indexes (and those of the types above it) for the whole branch that joins it: the
type and every type below it, at any depth, since their records become records of the super-type too. A UNIQUE key
that clashes anywhere in that branch refuses the statement in the same way, with nothing changed. (Since v26.12.1,
issue #12036. Before, only the type’s own records were indexed: a UNIQUE index was not enforced for the records of its
sub types, and SEARCH_INDEX and vectorNeighbors did not return them. In a database where the super-type was assigned
on an earlier version, removing it and assigning it again builds the missing entries.)
|
Assigning a super-type is refused, before anything changes, when a stored record of the type, or of a type below it,
violates a property the type would inherit from it (or from the types above it): a MANDATORY property the record lacks, a
NOTNULL one it holds as null, a value of another type than the declared one, or a value outside its MIN, MAX or
REGEXP. This is the check CREATE PROPERTY and ALTER PROPERTY apply to existing records. The message names the first
violating record and the reason, for example Cannot make type 'T' a sub type of 'S': record #1:0 violates the properties
it would inherit, The property 'T.p' value 5 is less than 10. Fix or delete the non-conforming records first. A property
the type already declares itself with the same type is governed by that declaration and not checked again. The check reads
the records of the type and its sub types, so on a large type the statement takes as long as that scan. (Since v26.12.1,
issue #12030. Before, the statement was accepted, and every later write to such a record failed, even one that did not
touch the inherited property.)
|
Assigning a super-type is refused, before anything changes, when it declares a property with another type (or another
OF type) than a declaration of the same name that the type, or a type below it, already sees: for example P.x FLOAT against
a sub type that declares x DATETIME. One name cannot have two types in a hierarchy, because an index of the super-type on x
would hold the records of the sub type under keys of the other type. The message names the property and the two types. A
declaration of the same type stays accepted, with a warning in the log, and CREATE PROPERTY applies the same rule (see
CREATE PROPERTY). A database that already holds such an overlap still opens, and DROP TYPE can
still re-attach the sub types of the type it drops. (Since v26.12.1, issue #12732. Before, the statement was accepted
whatever the types were: lookups through the super-type’s index missed the records of the sub type, a BINARY against a
number left an index file that could not be read, and a BY KEY, BY ITEM or GEOSPATIAL index over a property of another
type answered 500 or refused every later insert.)
|
Removing a super-type is refused, and nothing changes, while an index of the type or of a type below it stands on a
property that type would stop inheriting, the same rule DROP PROPERTY applies. The message names the property and the
index: drop the index first, declare the property on the type, or add a super-type that provides it before removing the
old one. The changes of one statement are applied in the order written, so to swap two super-types that both declare the
property write the addition first (ALTER TYPE C SUPERTYPE +Q, -P); SUPERTYPE -P, +Q is refused at the removal. A removal
is also refused when the property would then be inherited from another super-type with a different type (for example
STRING instead of the INTEGER the index is keyed on). DROP TYPE applies the same rule to the sub types of the dropped
type (see DROP TYPE). (Since v26.12.1,
issue #12038. Before, the removal was accepted and left the index keyed on a property the type no longer declared, so
values were stored with one type and indexed with another.)
|
-
Add the "account2" bucket to the type
Account.
ArcadeDB> ALTER TYPE Account BUCKET +account2
In the event that the bucket does not exist, it automatically creates it.
The statement is refused when the bucket belongs to another type, or when another type keeps it for its own use (the paired
ext bucket of its EXTERNAL properties, the _out_edges and _in_edges buckets of one of its vertex buckets, a bucket of its
super-node stripe pool). On a vertex type it is also refused when the _out_edges or _in_edges bucket of the bucket added already
belongs to another type. The error names the other type, and the schema is left as it was. _(Since v26.12.1.)
-
Remove the bucket
account_34from the typeAccount(buckets are referenced by name):
ArcadeDB> ALTER TYPE Account BUCKET -account_34
The records stay in the bucket, but they no longer belong to any type. They can still be read and deleted, for example with SELECT FROM BUCKET:account_34, DELETE FROM BUCKET:account_34 or TRUNCATE BUCKET account_34, and they are returned without @type. Updating one is refused with an error that names the bucket: attach the bucket to a type with ALTER TYPE … BUCKET + to update it again. (Since v26.12.1, issue #11335. Before, reading such a record as JSON, updating it and deleting it each failed with a NullPointerException.)
-
Modify the bucket selection strategy to
partitionedselecting the property id as partition key:
ArcadeDB> ALTER TYPE Account BucketSelectionStrategy `partitioned('id')`
-
Set the custom value with key 'description':
ArcadeDB> ALTER TYPE Account CUSTOM description = 'All users'
-
Set the custom nested value with key 'meta':
ArcadeDB> ALTER TYPE Account CUSTOM meta = { abool: true, alist: [1,2,3,4,5]};
-
Change the type name from 'Account' to 'Client':
ArcadeDB> ALTER TYPE Account NAME Client;
Renaming a type carries what is bound to it by name: its buckets and indexes (those it declares and the sub-indexes it holds for the indexes of its super types; renaming a super type leaves the sub-indexes of its sub types as they are), the files a TIMESERIES type keeps its samples in (the mutable bucket and sealed file of each shard, and the tag dictionary; the rename is refused, before anything is changed, when a file of that name is already in the database directory; when that name is held by a bucket, such as X_shard_0 for a rename to X, the refusal is an "already exists" conflict, HTTP 409), the materialized views and continuous aggregates that read it (their stored source type and the FROM of their defining query), the triggers defined on it, and the graph analytical views that list it (their definition is updated and the view rebuilt). The rename is refused, before anything is changed, when the type is the backing type of a materialized view or a continuous aggregate (it is named after the view), or when a view’s query names the type in a form that cannot be re-pointed with certainty. (Since v26.11.1. Before, a view or an aggregate kept naming the old type: its refresh failed, DROP TYPE on the renamed source was let through, and a trigger came back unbound after a restart. A renamed TIMESERIES type came back empty after a restart, its samples left in the files named after the old type.) (Since v26.12.1 this holds for LSM_VECTOR indexes too, issue #12035. Before, their per-bucket indexes kept the old type name, so SELECT FROM schema:indexes failed with Type with name '…' was not found until a restart, and a type created later under the old name was listed as their owner.)
|
A property declared EMBEDDED, LINK, LIST or MAP OF the renamed type follows the rename too, and new embedded documents of the renamed type can be written, whether the property declares the type or not. (Since v26.12.1, issue #11305. Before, the property kept the old name and every write of it failed with "Type with name … was not found", and no embedded document of the renamed type could be written at all.) An embedded document written BEFORE the rename still names the old type and is not read back until the type is renamed back (issue #11336): rename a type that holds embedded documents only once the data can be re-imported.
|
An index with the default name follows the rename: Account[id] becomes Client[id], and DROP INDEX and REBUILD INDEX find it by the new name at once (the old name no longer resolves). An index created with a name of its own (CREATE INDEX AccountIds ON Account (id) UNIQUE) keeps that name across the rename and across a restart. A rename is refused, and nothing changes, when an index of the type would take a name another index already has. (Since v26.11.1. Before, the index was listed under the new name but resolved only by the old one, and a name of its own was replaced by the default one.) An index created with the default name written out (CREATE INDEX ) counts as an index with the default name and follows the rename too, TRUNCATE TYPE after it included. (Since v26.12.1, issue #12774. Before, an LSM_SPARSE_VECTOR index that had been through REBUILD INDEX came back from TRUNCATE TYPE under the old type name, for example Account[tk,wt] on the type Client, and was saved that way: vectorSparseNeighbors on that name failed with Type with name 'Account' was not found and a new type Account could not get the same index.)
|
-
Add the former type name 'Account' as alias for 'Client':
ArcadeDB> ALTER TYPE Client ALIASES Account;
Using ALIASES overwrites any previous ALIASES of this type.
|
A statement that names the type by an alias answers what it answers with the type’s name, an index used or not: SELECT, UPDATE and DELETE, MATCH (type:) and INSTANCEOF, on the type and on its sub-types. (Since v26.12.1, issue #12968. Before, a statement through an alias that the planner answered with an index returned no rows, and an UPDATE or DELETE reported count: 0 and changed nothing.)
|
For more information, see:
Supported Attributes
| Attribute | Type | Description |
|---|---|---|
|
Identifier |
Changes the type name. |
|
Identifier(s) |
Add one or more (comma-separated) alternate name(s) for the type name. |
|
Identifier |
Defines a super-type for the type. Use |
|
Identifier |
Name of the bucket: |
|
Identifier |
Change the selection of the bucket when new records are created. Using |
SQL - DROP TYPE
Removes a type from the schema. To drop a type (safely), first, all its instances need to be removed.
Syntax
DROP TYPE <type> [IF EXISTS] [UNSAFE]
-
<type>Defines the type you want to remove. -
IF EXISTSPrevent errors if the type does not exist when attempting to drop it. -
UNSAFEDefines whether the command drops non-empty edge and vertex types. Note, this can disrupt data consistency. Be sure to create a backup before running it.
Bear in mind, that the schema must remain coherent.
For instance, avoid removing types that are super-types to others.
The buckets of the type are dropped with it, together with the paired _ext buckets that hold the values of its EXTERNAL properties.
|
An edge type whose edges are all lightweight is refused without UNSAFE, as any edge type that still has edges is. (Since v26.11.1, issues #10923 and #11142. Before, the check looked for edge records only, so the drop went through and left entries in the vertices that no command could read or delete.)
|
The paired ext bucket of a bucket detached from the type earlier (with ALTER TYPE … BUCKET -) is kept, since the records of the detached bucket still point into it. _(Since v26.12.1, issue #12995. Before, DROP TYPE left every paired _ext bucket behind: its file stayed on disk with the EXTERNAL values, it stayed in the schema, CHECK DATABASE counted its records, and a type created later under the same name took it over with the old values.)
|
DROP TYPE is refused, even with UNSAFE, while a materialized view, a continuous aggregate or a graph analytical view reads the type. Drop the view first. (Since v26.11.1 for graph analytical views. Before, the drop went through and the view failed to build at the next open.)
|
DROP TYPE is refused, even with UNSAFE, while a property of another type is declared EMBEDDED, LINK, LIST or MAP OF the type (or of one of its aliases). The message names the property: drop it first with DROP PROPERTY <Type>.<property>. A property of the dropped type itself, one declared of its own type included, goes with it. (Since v26.12.1, issue #11305. Before, the drop went through and every write of the property, and every read of a record holding one, failed to resolve the type.)
|
Dropping a type links its sub types directly to its super types. When that would link a sub type directly under the backing type of a materialized view or a continuous aggregate, or under a type below one, DROP TYPE is refused before anything is changed, with a message naming the link to take out first, for example ALTER TYPE `Deep` SUPERTYPE -`Mid` to drop Mid out of Deep -> Mid -> <view>. Once that link is removed, the drop goes through. Such a chain exists only in a database written before 26.11.1, which refuses a type extending a backing type (issue #11204). (Since v26.12.1, issue #11272. Before, the drop linked the sub type under the backing type anyway.) The same refusal applies
when the new direct link would join types of different kinds, which only a database written before 26.12.1 can hold (for example a
document type under a vertex type under another vertex type: dropping the middle type is refused, naming the link to take out first).
A hierarchy that follows the rule can be dropped from the middle as before. (Since v26.12.1, issue #12029.)
|
DROP TYPE is refused, even with UNSAFE, while an index of one of its sub types (at any depth) stands on a property that sub type would no longer inherit after the drop, the same rule DROP PROPERTY applies. For example, with C EXTENDS P, P.k declared only on P and an index C[k], DROP TYPE P answers Cannot drop the type 'P' because the property 'k' that type 'C' would no longer inherit is used by index 'C[k]' and changes nothing: drop the index first, or declare the property on the sub type. A property the sub type keeps does not count: one it declares itself, one it inherits through another super type, or one declared by a super type of the dropped type. The dropped type’s own indexes are dropped with it, as before. (Since v26.12.1, issue #12318. Before, the drop went through and left the index keyed on a property no type declared, so values were stored with one type and indexed with another.)
|
A database written by a version affected by issue #8169 can still contain a type that was dropped but came back after a restart with no buckets: inserting into it fails with Cannot retrieve a bucket for type … because there are no buckets associated. The database logs a warning at open naming every type that has no buckets and no subtypes, and DROP TYPE <name> removes such a type permanently.
|
DROP TYPE, ALTER TYPE … BUCKET - and ALTER TYPE … SUPERTYPE - ask what can refuse them before they change anything, and take the locks of the index files they delete once, up front. A file that cannot be deleted (it is not a regular file, or its directory cannot be written), an index that names a type that does not exist, or a lock another thread holds refuses the statement with the schema as it was (Nothing was changed; a lock refusal is retryable). It is a pre-check, not a guarantee: a disk error on one of the deletes after it passed is not undone, and leaves the statement part way. (Since v26.11.1, issue #10421. Before, a refusal part way left the sub types unlinked and the indexes before it dropped, and saved that.)
|
|
The same applies to Before that version, these three commands returned no rows at all when the object didn’t exist. |
Examples
-
Remove the type
Account:
ArcadeDB> DROP TYPE Account
For more information, see:
SQL - TRUNCATE TYPE
Deletes records of all buckets defined as part of the type.
By default, every type has an associated bucket with the same name. This command operates at a lower level than DELETE. This commands ignores sub-types, (That is, their records remain in their buckets). If you want to also remove all records from the type hierarchy, you need to use the POLYMORPHIC keyword.
Truncation is not permitted on a vertex or edge type that holds records, but you can force its execution using the UNSAFE keyword. Forcing truncation is strongly discouraged, as it can leave the graph in an inconsistent state. With POLYMORPHIC, the refusal covers the whole hierarchy below the type, and the error names the type that actually holds the records.
Add UNSAFE where the truncation is intended:
TRUNCATE TYPE Person UNSAFE
TRUNCATE BUCKET refuses in the same way, so the two commands agree on the same data.
Syntax
TRUNCATE TYPE <type> [ POLYMORPHIC ] [ UNSAFE ]
-
<type>Defines the type you want to truncate. -
POLYMORPHICDefines whether the command also truncates the type hierarchy. -
UNSAFEDefines whether the command forces the truncation on vertex or edge types.
Transactions
TRUNCATE TYPE behaves differently depending on whether a transaction is already active when it runs, and the result set reports which of the two applied through the transactional field:
-
Inside a transaction (
transactional: true) the truncate is part of that transaction: the records are deleted with the type’s indexes maintained record by record, and aROLLBACKputs every record back. This is the behaviour to rely on when the truncate is one half of a reload, e.g.BEGIN; TRUNCATE TYPE Staging UNSAFE; INSERT …; COMMIT;- if the insert fails, the previous contents survive. Thearcadedb.truncateBatchSizesetting does not apply. -
With no transaction active (
transactional: false) the command owns a transaction of its own and takes a faster path: it drops the type’s indexes, deletes the records in batches ofarcadedb.truncateBatchSize(default 1000), each committed separately, and recreates the (empty) indexes at the end. This is considerably cheaper on a large type, but the command commits as it goes, so it cannot be undone.
Over HTTP the request’s auto-commit transaction is what makes the command transactional; pass "autoCommit": false in the request payload to select the faster, non-undoable path for a bulk clear.
On a TIMESERIES type (since 26.11.1) the command removes samples, and it never takes part in the transaction it runs in, whatever the paragraphs above say of other types: the samples are gone, durably, when the statement returns, and a ROLLBACK does not bring them back (the result carries transactional: false, with the count of the samples removed). DELETE FROM a TIMESERIES type behaves the same way. See Deleting Samples.
|
A lightweight edge type with a subtype is an exception to "ignores sub-types by default": since a lightweight edge has no bucket of its own, the command refuses without POLYMORPHIC instead of silently truncating only part of the hierarchy.
|
Examples
-
Remove all records of the type
Profile:
ArcadeDB> TRUNCATE TYPE Profile
For more information, see: