How to rename a database in RethinkDB
Asked Answered
M

1

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?

Maulmain answered 31/3, 2015 at 21:15 Comment(1)
This was removed from the UI in a recent rewrite, but it should come back eventually (github.com/rethinkdb/rethinkdb/issues/3825) is the issue to track if you're interestedDissipated
C
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'})
Coal answered 31/3, 2015 at 23:53 Comment(2)
This doesn't seem to get mentioned in the documentation at all. -.-Maulmain
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'})Zing

© 2022 - 2024 — McMap. All rights reserved.