Null value operation

Source: Internet
Author: User

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

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.