Buckets

SQL - CREATE BUCKET

Creates a new bucket in the database. Once created, you can use the bucket to save records by specifying its name during saves. If you want to add the new bucket to a type, follow its creation with the ALTER TYPE command.

Syntax

CREATE BUCKET <bucket> [IF NOT EXISTS] [ID <bucket-id>]
  • <bucket> Defines the name of the bucket you want to create. You must use a letter for the first character, for all other characters, you can use alphanumeric characters, underscores and dashes.

  • IF NOT EXISTS Specifying this option, the bucket creation is just ignored if the bucket already exists, instead of failing with an error. The statement returns one row either way, carrying a created flag: see the note on IF NOT EXISTS results.

  • <bucket-id> Defines the numeric ID you want to use for the bucket.

Examples

  • Create the bucket account:

ArcadeDB> CREATE BUCKET account

For more information see:

SQL - DROP BUCKET

Removes the bucket and all of its content. This operation is permanent and cannot be rolled back.

Syntax

DROP BUCKET <bucket-name>|<bucket-id> [IF EXISTS]
  • <bucket-name> Defines the name of the bucket you want to remove.

  • <bucket-id> Defines the ID of the bucket you want to remove.

  • IF EXISTS Prevent errors if the bucket does not exist when attempting to drop it. See here for the shape of the result.

Examples

  • Remove the bucket Account:

ArcadeDB> DROP BUCKET Account
A bucket cannot be renamed or altered (ALTER BUCKET was removed in v26.12.1). To move the records of a bucket to another one, create the new bucket, copy the records with MOVE VERTEX or INSERT …​ SELECT, then drop the old bucket. A copied record gets a new RID: rewrite the links that point to the old RIDs before DROP BUCKET, which deletes the source records.

For more information, see:

SQL - TRUNCATE BUCKET

Deletes all records of a bucket. This command operates at a lower level than the standard DELETE command.

Truncation is not permitted on vertex or edge types, 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.

Syntax

TRUNCATE BUCKET <bucket>
  • <bucket> Defines the bucket to delete.

  • UNSAFE Defines whether the command forces the truncation on vertex or edge types.

Transactions

As with TRUNCATE TYPE, the command is part of the caller’s transaction when one is active - a ROLLBACK puts every record back - and owns a transaction of its own, committing one batch of arcadedb.truncateBatchSize records at a time, when none is. The result set reports which applied through the transactional field.

Examples

  • Remove all records in the bucket profile:

ArcadeDB> TRUNCATE BUCKET profile

For more information, see: