Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the keyword AUTOINCREMENT of SQLite

Shulou Source: shulou.com Published: 2022-06-01 17:26:11 10月03日 Update

In this article, the editor introduces in detail "how to use the keyword AUTOINCREMENT of SQLite". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to use the keyword AUTOINCREMENT of SQLite" can help you solve your doubts.

Autoincrement means automatic increment in Chinese. T is a keyword in SQLite, which is used to automatically increment the values of fields in a table. You can use the AUTOINCREMENT keyword on a specific list name to automatically increase the value of this field when you create a table.

Grammar

The basic usage of the AUTOINCREMENT keyword is as follows:

CREATE TABLE table_name (column1 INTEGER AUTOINCREMENT, column2 datatype, column3 datatype,. ColumnN datatype,); instance

Suppose the COMPANY table to be created is as follows:

Sqlite > CREATE TABLE COMPANY (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (50), SALARY REAL)

Now, insert the following record into the COMPANY table:

INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ('Paul', 32,' California', 20000.00); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ('Allen', 25,' Texas', 15000.00); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ('Teddy', 23,' Norway', 20000.00); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ('Mark', 25,' Rich-Mond', 65000.00) INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ('David', 27,' Texas', 85000.00); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ('Kim', 22,' South-Hall', 45000.00); INSERT INTO COMPANY (NAME,AGE,ADDRESS,SALARY) VALUES ('James', 24,' Houston', 10000.00)

This inserts seven tuples into the COMPANY table, and the record of the COMPANY table is as follows:

ID NAME AGE ADDRESS SALARY--1 Paul 32 California 20000.02 Allen 25 Texas 15000.03 Teddy 23 Norway 20000.04 Mark 25 Rich-Mond 65000.05 David 27 Texas 85000.06 Kim 22 South-Hall 45000.07 James 24 Houston 10000.0 read here This article "how to use the keyword AUTOINCREMENT of SQLite" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about the article, please follow the industry information channel.

Tags: Keywords keywords articles content fields meaning appropriateness names examples that is ideas new knowledge more steps knowledge knowledge points articles details industry grammar Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology MariaDB Linux Shulou Tech Info