sqliteHow do I alter a table in SQLite?
To alter a table in SQLite, you use the ALTER TABLE
statement. This statement allows you to add, remove, or modify columns in an existing table.
For example, to add a new column named date_created
to the customers
table, you use the following statement:
ALTER TABLE customers
ADD COLUMN date_created DATE;
This statement adds a new column named date_created
to the customers
table. The column is of type DATE
, which stores date and time values.
You can also use the ALTER TABLE
statement to modify the data type of an existing column, rename an existing column, or drop an existing column.
For example, to modify the data type of the date_created
column to TEXT
, you use the following statement:
ALTER TABLE customers
MODIFY COLUMN date_created TEXT;
To rename the date_created
column to created_at
, you use the following statement:
ALTER TABLE customers
RENAME COLUMN date_created TO created_at;
To drop the created_at
column, you use the following statement:
ALTER TABLE customers
DROP COLUMN created_at;
More information about the ALTER TABLE
statement can be found in the SQLite documentation.
More of Sqlite
- How do I use SQLite with Zephyr?
- How do I list all tables in a SQLite database?
- How do I download and install SQLite zip?
- How do I set up an ODBC driver to connect to an SQLite database?
- How do I use the SQLite ZIP VFS to compress a database?
- How do I format a date in SQLite using the YYYYMMDD format?
- How do I use SQLite xfilter to filter data?
- How to configure SQLite with XAMPP on Windows?
- How can I use SQLite to query for records between two specific dates?
- How do I use the SQLite sequence feature?
See more codes...