Raise a dialog for table changing. This dialog looks quite similar like that "Create Table" one except for a few things:
The built-in Sqlite ALTER TABLE command is very limited since it can only rename the table or add a single column at a time.
Sqliteman provides a more general ALTER TABLE by creating a new table, copying the data, and dropping the old table. If necessary the old table is renamed out of the way first. However Sqliteman has limited understanding of the many possible table structures. In this version some information is lost if alterations to a table do anything other than renaming it. In that case columns can be added or deleted, and column types, default values, NOT NULL constraints, and PRIMARY KEY and AUTOINCREMENT constraints can be modified or preserved. Triggers are preserved (but cannot be modified) as long as the columns to which they refer are not deleted or renamed. Indexes are preserved (but cannot be modified) unless a column to which an index refers is deleted: renaming indexed columns is handled. Constraint names, conflict clauses, foreign key clauses, DESC tags, UNIQUE constraints, CHECK constraints, and COLLATE constraints are all lost. These can be preserved by manually renaming the old table, doing "Describe Table", copying and pasting the description into the SQL editor, modifying it as required and creating a new table, copying the data, and then dropping the old table.
In any case views and foreign key constraints referring to the altered table will be left dangling if the table is renamed or the columns referred to are renamed or deleted. This is behaviour of sqlite itself and not specific to Sqliteman.
In this dialog you can
and table columns and set the options for new ones.The Alter button is enabled only when at least something has changed from the original table definition, and the table name is nonempty, and all column names are different, and if there is an AUTOINCREMENT column its type is INTEGER and no other column is a PRIMARY KEY, and if Without rowid is checked there is at least one PRIMARY KEY column.
Sqlite will permit a table to be created with a table name which contains non-alphanumeric characters or with an empty string as a column name, so sqliteman allows these. However in both of these cases it asks if you really want to do it, since the underlying library doesn't display such tables correctly.
Remember triggers and indexes from the original table
Rename the original table with temporary name if it is a case-insensitive match for the new name
Create new table with new name containing new column structure
Perform INSERT INTO new table SELECT FROM (possibly renamed) old table
Drop old table
Try to recreate original indexes and triggers
When there is no change other than the name, only the rename is performed.
The whole process is performed within a SAVEPOINT: if any error occurs the database is rolled back to the savepoint, reinstating the original table.