SQLite SQL statements

Source: Internet
Author: User

ALTER Table statement:

ALTER TABLE
Sql-statement:: = ALTER TABLE [database-name.] Table-name Alteration
Alteration:: = RENAME to New-table-name
Alteration:: = ADD [COLUMN] Column-def


The RENAME to syntax is used to rename the table name [Database-name.] Table-name to New-table-name. This command cannot be used to move tables between attached databases, and tables can only be renamed in the same database.

The add [COLUMN] syntax is used to add a new field to an existing table. The new field is always added to the end of the existing field list. Column-def can be any form that is allowed in create table and is subject to the following restrictions:

A field cannot have a primary key or a unique constraint.
Fields cannot have these default values: Current_time, current_date, or Current_timestamp
If a NOT NULL constraint is defined, the field must have a non-empty default value.

The SQLite version of the ALTER TABLE command allows the user to rename or add new fields to existing tables, cannot remove fields from the table, and can only add columns at the end of the table

The ALTER table statement's execution time is independent of the amount of data in the table, which is the same as when you operate a table with 10 million rows, and when you manipulate a table with only one row.

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.