Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename a DynamoDB table

I have DynamoDB table and I would like to rename it. There does not seems to be any commands or options to rename a table. Has anybody renamed a table before?

like image 370
Gowtham Avatar asked Jan 28 '14 16:01

Gowtham


People also ask

Can you change DynamoDB table name?

It's not actually possible to rename a DynamoDB table. A common workaround is to create a new table and copy the data (it is also possible to use AWS Data Pipeline to export/import data via S3).

Is DynamoDB table name unique?

In an AWS account, table names must be unique within each Region. That is, you can have two tables with same name if you create the tables in different Regions. CreateTable is an asynchronous operation. Upon receiving a CreateTable request, DynamoDB immediately returns a response with a TableStatus of CREATING .

How do I edit items in DynamoDB table?

To update an existing item in an Amazon DynamoDB table, you use the UpdateItem operation. You must provide the key of the item that you want to update. You must also provide an update expression, indicating the attributes that you want to modify and the values that you want to assign to them.


5 Answers

I know this is an old question and I don't want to steal the thunder from user6500852's answer but for anyone stumbling upon this needing an answer:

  1. Select the table you want to rename in the Web UI so it's highlighted and the various tabs show up to the right.

  2. Click on the Backups tab and feast your eyes upon the lower half of the page ("On-Demand Backup and Restore").

Backup Area 3. Smash that "Create Backup" button. You'll be prompted for a backup name. Name it whatever you want. The world is yours!

  1. Give it time to complete the backup. If you just have a few records, this will be seconds. If you have a ton of records it could be hours. Buckle up or just go home and get some rest.

  2. Once the backup is ready, highlight it in the list. You'll see the "Restore Backup" button light up. Click it.

  3. You'll get a prompt asking you to enter the NEW table name. Enter the name you wanted to rename this table to. Note: the way the UI is you may have to click out of the field in the static page area for the "Restore table" button at the bottom of the page to light up. Restore Form

  4. Once you're ready to go, you click on the "Restore table" button. Note the info on that page indicating it can take several hours to complete. My table with just five test records took over 10 minutes to restore. I thought it was because the original was a Global Table but the restored table was NOT set up as a Global Table (which defeats the purpose of this for Global Tables since you have to empty the table to make it global).

Bear in mind that last note! If you're working with a Global Table, you will lose the Global part after the restore. Buyer beware! You may have to consider an export and import via Data Pipeline...

If you're not, then the Backup and Restore is a pretty easy process to use (without having to go and setup a pipeline, S3 store, etc.). It can just take some time.

Hope this helps someone!

like image 182
KenLFG Avatar answered Oct 04 '22 12:10

KenLFG


Currently no, you would need to create a new table and copy the data from one to the other if you really needed a new table name.

like image 26
E.J. Brennan Avatar answered Oct 04 '22 10:10

E.J. Brennan


You can use the Export/Import feature to backup your data to S3. Then delete your old table, and create a new one with the new name. Import your data from S3. Done. No code change necessary. If you don't delete CloudWatch alarms and Pipelines when deleting the old table, then those will automatically hook up to the new table. The ARN even stays the same.

The downside to this, of course, is that the table will be unusable during the time after you delete it and before you recreate it. This may or may not be a problem, but that needs to be considered. Additionally, once you recreate the table, it can be accessed while you work on the data import. You may want to stop your app's access to the table until the import is complete.

like image 23
Daniel Phelps Avatar answered Oct 04 '22 11:10

Daniel Phelps


Create first backup from backup tab. While creating restore backup, it prompt with request of new table name.

In that we can apply new/backup table name.

Hope this will help.

like image 38
user6500852 Avatar answered Oct 04 '22 11:10

user6500852


You should be able to achieve this using on demand backup / restore functionality.

Check out a walk through on backing up a table, and restore to a new table:

https://www.abhayachauhan.com/2017/12/dynamodb-scheduling-on-demand-backups/

like image 28
Abhaya Chauhan Avatar answered Oct 04 '22 12:10

Abhaya Chauhan