SQLite Learning Note 5: Inserting data, querying data, and deleting data

Source: Internet
Author: User
Tags sqlite

Zeng: All programming is data-centric, and it makes sense.

The so-called database database, no data called what database, then see how to insert data in the table.


One insert data

1 Creating a Table

To insert the data first, you need to create a table first:

CREATE TABLE Company (   ID int PRIMARY KEY isn't     null,   NAME           TEXT not    null,   age            INT     not NULL,   ADDRESS        CHAR (+),   SALARY         REAL);


2 First way: Specify columns

There are two basic formats for inserting data, the first of which is the specified column, and the syntax is as follows:

INSERT into table_name (column1, Column2, Column3,... columnn)]  VALUES (value1, value2, value3,... Valuen);
For example:

INSERT into Company (id,name,age,address,salary) VALUES (1, ' Hanfeng ', +, ' Hubei ', 10000.00);

In this way, only the NOT NULL column is given a value, and the other columns that are not specified can be empty


3 Second way: Full column

The second way to insert is to not know the column, but to specify a value for each column, it is important to note that the order must be consistent.

INSERT into table_name VALUES (value1, value2, value3,... Valuen);


Two data query

1 Querying the specified column

Query values a value for the specified column in a table:

SELECT column1, Column2, COLUMNN from table_name;

2 querying the values of all columns in a table

SELECT * FROM table_name;


3 Setting the output format

. Header on-Displays a list of. Mode column--sets the column to its


Three delete data

Basic syntax:

DELETE from Table_namewhere [condition];







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.