Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename a database in RethinkDB

Tags:

rethinkdb

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?

like image 777
adius Avatar asked Mar 31 '15 21:03

adius


1 Answers

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'})
like image 181
Jorge Silva Avatar answered Nov 03 '22 18:11

Jorge Silva