ALTER TABLE Command in SQLite
This command is used to change the structure of a table that is already present in the database schema. SQLite supports only some of the functionalities of the ALTER TABLE command which is not the case with other SQL databases. So, let’s see how to perform changes in the database table using the ALTER TABLE command.
Using SQLite ALTER TABLE to Rename a Table
To rename a table, you can use the following syntax
ALTER TABLE old_table RENAME TO new_table;
For Example:
CREATE TABLE users (
user_id INTEGER PRIMARY KEY,
username TEXT
);
ALTER TABLE users RENAME TO customers;
Output:
Here we created a table named users in our database which is then renamed to customers. Random data has been inserted into the table to make things more clear.
SQLite Alter Table
SQLite is a serverless architecture that we use to develop embedded software for devices like televisions, cameras, and so on. It is written in C programming Language. It allows the programs to run without any configuration. In this article, we will learn everything about the ALTER TABLE command present in SQLite. In SQLite, the ALTER TABLE
statement empowers you to make changes to the structure of an existing table without the need to recreate it entirely.