Data Loss Warning: This operation permanently deletes all data in the table.

Syntax

r.tableDrop(tableName) → result
r.db(dbName).tableDrop(tableName) → result

Arguments

List of arguments to provide.
tableName
string
required
Name of the table to drop. Must be an existing table name within the database.

Optargs

No optional arguments.

Returns

result
object
Information about the operation.

Behavior

  • When called without a database context (r.tableDrop()), operates on the default database.
  • When called with a database context (r.db().tableDrop()), operates on the specified database.
  • Permanently deletes the specified table and all its documents.
  • All secondary indexes associated with the table are also deleted.
  • The operation is atomic - either the table is completely dropped or an error occurs.
  • Once dropped, the table and its data cannot be recovered unless you have backups.
  • If the table doesn’t exist, an error is thrown.

Notes & Caveats

  • All secondary indexes on the table are automatically dropped.
  • Any ongoing queries on the table will fail after the table is dropped.
  • Reserved system tables cannot be dropped.
  • Consider creating backups before dropping important tables.

Example

Drop a simple table

Drop a table from the default database.
const result = await r.tableDrop('temp_data').run(client);

console.log(`Dropped ${result.dropped} table(s)`);

Drop a table from specific database

Drop a table from the ecommerce database.
const result = await r.db('ecommerce').tableDrop('old_orders').run(client);

console.log(`Dropped ${result.dropped} table(s)`);

Drop multiple tables

Drop several related tables in sequence.
const tablesToDrop = ['temp_users', 'temp_posts', 'temp_comments'];

for (const tableName of tablesToDrop) {
  try {
    const result = await r.db('staging').tableDrop(tableName).run(client);

    console.log(`Dropped table: ${tableName}`);
  } catch (error) {
    console.error(`Failed to drop ${tableName}:`, error.message);
  }
}
  • r - Referencing the query builder
  • db - Referencing a database
  • table - Referencing a table
  • tableCreate - Creating a table
  • tableList - Listing tables
  • delete - Deleting documents (alternative to dropping entire table)
  • dbDrop - Dropping an entire database

Found a typo? Or maybe a broken link? RuloDB is open-source, help us fix it!