To retrieve the data from the table according to the user's instruction is called as query. The select statement can be used to retrieve information from a database. The select statement can be used for:
Where select identifies which columns
From identifies which table
Table specifies the table from which the data has to retrieve.
The above statement will retrieve all the records of dept table.
The above statements will retrieve the dept-id, dept-name, manager-id column from dept table.
Sometimes you may need to modify the way in which data is displayed or perform calculations. All these operations are possible using arithmetic expression. An arithmetic expression can contain column names, constant numeric values, and arithmetic operator. Some arithmetic operators are given below:
The above example will show emp-name, emp-sal and their increased salary, which is Rs. 3000/- more from the actual salary.
Whenever oracle server returns the result of a query normally it uses the name of the selected column heading. This heading may not be descriptive hence it may be difficult to understand. You can change the column heading by using a column alias. By default, alias headings appear in uppercase. If the alias contains spaces or special characters(such as # or $), or is case sensitive, enclose the alias in double quotation marks( " " ).
In the above example the query will return that the column heading emp-name as EMP-NAME.
A concatenation operator :
In this example, last_name and job_id are concatenated, and they are given the alias Employee. It is pointed that the employee last name and job code are combined to make a single output column.
If you want to display rows based on range of a value in that case the between....and...operator is used.
In the above example the query will return all the value of emp-name and emp-salary where emp-salary falls between 12000 and 25000.
Note: the between....and....operator includes the lower limit as well as upper limit.
The in operator can be used in a situation where you have to make a search based on a list of values.