DROP DATABASE

Drops a database.

Syntax

DROP DATABASE [IF EXISTS] <database_name> [FORCE]
DROP SCHEMA [IF EXISTS] <database_name> [FORCE]
DROP DETACHED DATABASE <database_name> [STORAGEID <storage_id>] [COMPUTEID <compute_id>]

Note

The DROP DETACHED DATABASE command is a Preview feature.

Arguments

  • <database_name>: The name of a SingleStore database.

  • <storage_id> (Optional): The STORAGE_ID extracted from information_schema.MV_CLOUD_BRANCHES for the respective database.

  • <compute_id> (Optional): The LATEST_COMPUTE_ID extracted from information_schema.MV_CLOUD_BRANCHES for the respective database.

Remarks

  • By default, the DROP DATABASE command waits for the running queries to finish before dropping the database. To override this behavior and kill any running queries, use the FORCE option.

  • This command causes implicit commits. Refer to COMMIT for more information.

  • The DROP DATABASE command cannot be run on system databases.

  • The DROP DATABASE command drops the Point-In-Time Recovery (PITR) history. A database cannot be restored to the PITR milestone taken before the database was dropped.

  • The DROP DETACHED DATABASE command drops a database which was previously detached.

  • In the DROP DETACHED DATABASE command, the STORAGEID and COMPUTEID clauses apply when multiple entries exist in information_schema.MV_CLOUD_BRANCHES for the same database name.

  • Refer to the Permission Matrix for the required permission.

Dropping a Database in a Workspace

Executing  DROP DATABASE in a workspace can be only done from the primary R/W database. If a database is detached, it can be dropped in the cloud portal by selecting Drop Database from the three dots (ellipsis) in the database card under Deployments > Overview. If this command is run on the primary R/W database it will drop the database from all the workspaces including the read-only copies.

Examples

DROP DATABASE IF EXISTS test;
DROP DATABASE IF EXISTS db FORCE;

Example - DROP DETACHED DATABASE

DROP DETACHED DATABASE testdb;

If there are multiple databases with the same name, extract STORAGE_ID and LATEST_COMPUTE_ID.

SELECT STORAGE_ID, LATEST_COMPUTE_ID FROM information_schema.MV_CLOUD_BRANCHES
WHERE DATABASE_NAME=‘testdb’;

Use the STORAGE_ID and LATEST_COMPUTE_ID of the detached database in DROP DETACHED DATABASE command. Refer to MV_CLOUD_BRANCHES for more information.

DROP DETACHED DATABASE testdb STORAGEID 6362647530070456236:6577025878327007897 COMPUTEID 16245003384144080785:18098;
Query OK, 0 rows affected (2.05 sec)

Last modified: October 24, 2024

Was this article helpful?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK