M
M
Megach2020-08-15 19:13:15
SQLite
Megach, 2020-08-15 19:13:15

How to delete table field in sqlite3?

How to delete table field in sqlite3?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2020-08-15
@Megach

sqlite does not support the ability to delete a table column directly. You can work around this:
1. make a new table with only the required columns
2. add data from the old table to it with

INSERT INTO new_table_name (v1, v2) SELECT v1, v2 FROM old_table_name

3. delete (or rename) the old table
4. rename the new table as the old table was named
https://www.sqlitetutorial.net/sqlite-alter-table/

S
ScriptKiddo, 2020-08-15
@ScriptKiddo

1) Copy all the data to another table with a deleted column
2) Delete the main one, rename the new one
https://stackoverflow.com/a/8442173

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question