Wednesday 26 April 2017

Oracle SQL NULL Operators

NULL is an Unknown value. If there is nothing in any column of the table, then it is known as NULL value. NULL and Zero values are not same.  You cannot use NULL instead of zero because both are not equivalent.

If any arithmetic expression contains NULL, then its result will be always NULL.

Null operations in SQL

Using NULL with SQL functions.

NVL
You can use NVL operator to return a value if the NULL value occurs.
EX:-  NVL(Emp_Commission, 0)
It will return Zero value if the Emp_Commission is NULL or it will return the Emp_Commission if it is not null.

Compare NULL Value

IS NULL
You cannot check the NULL by using the comparison operators <, =, > and <>.
If you want to test NULL value, you can use IS NULL operator in the SQL query as shown below.

SELECT EMP_NO, EMP_NAME, SALARY
FROM EMP
WHERE BONUS IS NULL;

This query will return all records from EMP table whose BONUS column contains NULL value.

IS NOT NULL

You can also use IS NOT NULL operator for comparing NULL value.

The below query returns all employees whose Bonus is not null

SELECT EMP_NO, EMP_NAME, SALARY
FROM EMP
WHERE BONUS IS NOT NULL;




Tuesday 25 April 2017

Oracle SQL Tutorial for Beginners


If you are looking to learn Oracle SQL by your own, then this is the right place for you. This website content is designed in such a way that you can easily understand all the concepts of SQL theoretically as well as practically for Oracle Database. Let us have a glance at below sections of SQL tutorial.

1. Oracle SQL Introduction.

SQL or Structured Query Language is used to store, modify and retrieve data from database system. In order to access data from database, you need to write SQL queries. The data from database can be deleted, updated and retrieved by writing simple SQL commands. Before learning SQL commands, let us take a overview of the Database design.

2. What is Database?

Database is a storage unit which is used to store and access related information. You can easily maintain huge amount of data in a single database server. It makes easy to manage data in a multi-user environment where all users access database concurrently. 

In Database, the data is stored in the form of Table. Each table contains specific information like Employee details, Sales details, Customer details etc. The table contains many number of rows and columns as per the user requirement. Each column in the table is referred to as 'Field'.

3. SQL Statements

SQL has many statements that are used to perform actions on Oracle database. 
Some simple SQL statements are like 
SELECT
UPDATE
DELETE
are used to perform actions on Oracle database.

The detailed explanation of how to write SQL queries to fetch, modify or delete data from database will be explained in the next section.