Oracle Database/SELECT Statement

< Oracle Database

Listing the capabilities of SQL SELECT statements

A SELECT statement retrieves data from database. With a SELECT statement, you can use the following capabilities:

Executing a basic SELECT statement

    SELECT *|{[DISTINCT] column|expression [[AS] alias],...}
    FROM    table;
  1. SQL statements are not case-sensitive.
  2. SQL statements can be entered on one or more lines.
  3. Keywords like SELECT, FROM cannot be abbreviated or split across lines.
  4. In SQL Developer, SQL statements can optionally be terminated by a semicolon (;). Semicolons are required when you execute multiple SQL statements.
  5. In SQL*Plus, you are required to end each SQL statement with a semicolon (;).
    SELECT *
    FROM   hr.employees;
    SELECT employee_id, last_name, hire_date
    FROM   hr.employees;
    SELECT DISTINCT last_name
    FROM   hr.employees;
    SELECT last_name, salary, (salary+100-20)*105/100
    FROM   hr.employees;
    SELECT last_name AS name, commission_pct comm, salary*12 "Annual Salary"
    FROM   hr.employees;
    SELECT last_name || ' annually earns ' || salary*12
    FROM   hr.employees;
    SELECT last_name || '''s employee no is ' || employee_id
    FROM   hr.employees;
    SELECT last_name || q'<'s employee no is >' || employee_id
    FROM   hr.employees;
    DESC[RIBE] table

Describing various types of conversion functions that are available in SQL

Implicit data type conversion

Implicit conversion occurs when Oracle attempts to convert the values, that do not match the defined parameters of functions, into the required data types.

Explicit data type conversion Explicit conversion occurs when a function like TO_CHAR is invoked to change the data type of a value.

Using the TO_CHAR, TO_NUMBER, and TO_DATE conversion functions

Applying conditional expressions in a SELECT statement


Describing various types of functions available in SQL

Single row functions return one result per row.

Single row functions:

 Manipulate data items
 Accept arguments and return one value
 Act on each row that is returned
 Return one result per row
 May modify the data type
 Can be nested
 Accept arguments that can be a column or an expression

Character functions

 Case manipulation functions
   LOWER
   UPPER
   INITCAP

Using character, number, and date functions in SELECT statements


Including or excluding grouped rows by using the HAVING clause


This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.