1) Operation with null value writeCREATE TABLE j010 (ID number (7), name VARCHAR2, salary number (7,2)); When inserting, specify null INSERT INTO j010 (id,name,salary) VALUES (101, ' Scott ', null); Do not specify a field value default to null INSERT INTO j010 (id,name) VALUES (102, ' Bob '); Update field value to NULL update j010 set name=null where id=101;2) Null value to make conditional queryQuery salary for a record of NULL value SELECT * FROM j010 where salary is null; Query name NOT NULL worth recording select * from j010 where name was NOT null;3) Null value processing functionNVL (field, value 1): Returns a value of 1 if the field value is null; If not NULL, return the original field value//If the Salary field value is null, return 0, plus the +100 select ID,NAME,NVL (salary,0) from j010; Show name and salary, 0 when wages are null; The name is null when displayed ' anonymous ' select NVL (name, ' Anonymous '), NVL (salary,0) from j010; NVL2 (field, value 1, value 2): Returns a value of 2 if the field value is null; If the field value is not NULL return value 1//Display name and salary, wages are null when show ' no pay '//If not NULL when display ' confidential ' Select NAME,NVL2 (Salary, ' confidential ', ' unpaid ') from j010;4) Null value qualification (non-null constraint)The field value cannot be null if an error is given to the null value. CREATE TABLE j011 (ID number (7) not NULL, name VARCHAR2 (a) not null); Insert into j011 (id,name) values (101,null);//error INSERT INTO j011 (id,name) values (null,1000);//error INSERT INTO j011 (ID) VA Lues (102);//Error*2.null value OperationNull nullable values can be placed in each type field. If the number Type field value is null, it represents infinity. Other types of fields use NULL to indicate no value
Null value operation