SQLite Learning Note 4: Creating and Deleting tables

Source: Internet
Author: User
Tags sqlite

Before doing so much not just for the data to get a few tables, then see how to create a new table.

A new table

The basic syntax is as follows:

CREATE TABLE database_name.table_name (   column1 datatype  PRIMARY KEY (one or more columns),   column2 datatype ,   column3 datatype,   ...   .. COLUMNN datatype,);

where database_name is your database name, table_name of course is the table name, ColumnN is listed, Primary_key is the primary key, datatype is the data type of this column.

For example, create a new user table:

CREATE TABLE USER (   ID int PRIMARY KEY not     null,   NAME           TEXT not    null, age INT not     null,< C8/>address        CHAR (50));

# "Not NULL" specifies that the current column cannot be empty

After you are done, you can view the newly created table with the following command:

. Tables
To view the detailed structure of a table, use the command:

. Schema

Two Delete table

Use the command:

DROP TABLE Database_name.table_name;





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.