12

On the api documentation page rethinkdb.com/api/javascript I can only find commands to create, drop and list databases.

But how I can I rename a database in RethinkDB?

adius
  • 13,685
  • 7
  • 45
  • 46
  • This was removed from the UI in a recent rewrite, but it should come back eventually (https://github.com/rethinkdb/rethinkdb/issues/3825) is the issue to track if you're interested – deontologician Apr 02 '15 at 20:03

1 Answers1

23

You basically have two options:

1. Update the name using the .config method

You can also update the name using the .config method every database and tables has. This would look something like this:

r
  .db("db_name")
  .config()
  .update({name: "new_db_name"})

2. Update the db_config table

You can also execute a query on the db_config table and just do an update on the db you want to change. This would look something like this:

r   
   .db('rethinkdb')   
   .table('db_config')   
   .filter({ name: 'old_db_name' })   
   .update({ name: 'new_table_name'})
Jorge Silva
  • 4,574
  • 1
  • 23
  • 42
  • This doesn't seem to get mentioned in the documentation at all. -.- – adius Apr 01 '15 at 20:29
  • 5
    For anyone else finding this the last query should actually be: `r.db('rethinkdb').table('table_config').filter({name: 'old_table_name'}).update({name: 'new_table_name'})` – joakimbeng Feb 08 '17 at 13:14