Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Null Values

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 649
    Comment on it

    Null Values:

    Null values denotes missing data in a table or a database. If a column does not have any NOT NULL constraint then for that column there can be NULL values. By default a column can have NULL values.

    We cannot use comparison operators like =, >, < with null values. We can use IS NULL and IS NOT NULL operator to check whether there is a null value or not.

    Creating a table with no null values in it:

    CREATE TABLE Employees(
       EMPID   INT           NOT NULL,
       NAME VARCHAR (20)     NOT NULL,
       AGE  INT              NOT NULL,
       CITY  CHAR (25)       NOT NULL
       );
    

    In the above query NOT NULL keyword denotes that we have to provide some value for that column . We cannot left it blank, we must have to provide an explicit or a default value.

    IS NULL Operator Example:

    SELECT Name, City  FROM Employees WHERE City IS NULL;
    

    The above query will return those Employee names and cities whose City has NULL values.

    IS NOT NULL Operator Example:

    SELECT Name, City  FROM Employees WHERE City IS NOT NULL;
    

    The above query will return those Employee names and cities where City column has no null values in it .

     DELETE FROM Employees WHERE City IS  NULL;
    

    The above query will delete those employee records whose city column contain NULL value.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: