SQLite does not support modifying the primary key after the table is built, or deleting the column, if you want to modify it, refer to the following procedure

Source: Internet
Author: User
Tags sqlite

SQLite have limited ALTER TABLE support so can use the add a column to the end of a TABLE or to change the name of a T Able. If you want to make more complex changes in the structure of a table, you'll have the table with to recreate. You can save existing data to a temporary table, drop the old table, create the new table, and then copy the data. The temporary table.

For example, suppose you has a table named "T1" with columns names "A", "B", and "C" and so you want to delete column " C "from this table. The following steps illustrate how this could is done:

BEGIN TRANSACTION; CREATE temporary table T1_backup (A, b), INSERT into T1_backup SELECT A, from t1;drop table T1; CREATE table T1 (A, b); INSERT into T1 SELECT A, from T1_backup;drop TABLE t1_backup; COMMIT;

Http://sqlite.org/faq.html#q11

Http://stackoverflow.com/questions/946011/sqlite-add-primary-key

SQLite does not support modifying the primary key after the table is built, or deleting the column, if you want to modify it, refer to the following procedure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.