1.31. SQLite NULL value

发布时间 : 2025-10-25 13:32:42 UTC      

Page Views: 9 views

SQLite’s NULL Is an item used to represent a missing value. One of the tables NULL A value is a value that appears blank in the field.

With NULL A field with a value is a field without a value. It is important to understand that the NULL value is different from a zero value or a field that contains spaces.

1.31.1. Grammar

Use when creating a table NULL The basic syntax is as follows:

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

Here, NOT NULL Indicates that the column always accepts an explicit value of a given data type. There are two columns that we do not use NOT NULL, which means that they can be NULL .

With NULL The field of the value can be left blank when the record is created.

1.31.2. Example

The NULL value can cause problems when selecting data, because when comparing an unknown value with another, the result is always unknown and is not included in the final result. Suppose you have the following table, and the record for COMPANY is as follows:

ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 1 Paul 32 California 20000.0 2 Allen 25 Texas 15000.0 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0 6 Kim 22 South-Hall 45000.0 7 James 24 Houston 10000.0 

Let’s use UPDATE Statement to set some values that allow null values to be NULL , as follows:

sqlite> UPDATE COMPANY SET ADDRESS = NULL, SALARY = NULL where ID IN(6,7); 

Now, the record of the COMPANY table is as follows:

ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 1 Paul 32 California 20000.0 2 Allen 25 Texas 15000.0 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0 6 Kim 22 7 James 24 

Next, let’s take a look. IS NOT NULL Operator that is used to list all SALARY Not for NULL Record of:

sqlite> SELECT ID, NAME, AGE, ADDRESS, SALARY FROM COMPANY WHERE SALARY IS NOT NULL; 

Above. SQLite Statement will produce the following result:

ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 1 Paul 32 California 20000.0 2 Allen 25 Texas 15000.0 3 Teddy 23 Norway 20000.0 4 Mark 25 Rich-Mond 65000.0 5 David 27 Texas 85000.0 

The following is IS NULL Operator, all of which are listed SALARY For NULL Record of:

sqlite> SELECT ID, NAME, AGE, ADDRESS, SALARY FROM COMPANY WHERE SALARY IS NULL; 

Above. SQLite Statement will produce the following result:

ID NAME AGE ADDRESS SALARY ---------- ---------- ---------- ---------- ---------- 6 Kim 22 7 James 24 
《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。