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?

51856 次浏览

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.

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.

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/

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.

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!