How do you rename a table in SQLite 3.0?

Sqlite

Sqlite Problem Overview


How do you rename a table in SQLite 3.0?

Sqlite Solutions


Solution 1 - Sqlite

ALTER TABLE `foo` RENAME TO `bar`

SQLite Query Language: ALTER TABLE

Solution 2 - Sqlite

The answer remains to use "ALTER TABLE". But the main documentation page on this topic is pretty thick. What is needed is a simple example of how that works. You can find that here: https://www.sqlitetutorial.net/sqlite-alter-table/

To be precise, in the most basic case it looks like this:

ALTER TABLE existing_table
RENAME TO new_table;

I am not sure if the dot notation works, but I assume that the following is also correct:

ALTER TABLE existing_database.existing_table
RENAME TO new_database.new_table;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionreadonlyView Question on Stackoverflow
Solution 1 - SqliteJohn SheehanView Answer on Stackoverflow
Solution 2 - SqliteftrotterView Answer on Stackoverflow