Saturday, November 7, 2015

Oracle SQL: SELECT

To extract data from the database, you need to use the structured query language (SQL) SELECT statement.
A SELECT statement retrieves information from the database. With a SELECT statement, you can use the following capabilities:
  1. Projection: Choose the columns in a table that are returned by a query. Choose as few or as many of the columns as needed
  2. Selection: Choose the rows in a table that are returned by a query. Various criteria can be used to restrict the rows that are retrieved. 
  3. Joining: Bring together data that is stored in different tables by specifying the link between them. SQL joins are covered in more detail in a later lesson.
Basic SELECT Statement:
In its simplest form, a SELECT statement must include the following:
A SELECT clause, which specifies the columns to be displayed
A FROM clause, which identifies the table containing the columns that are listed in the SELECT clause
In the syntax: 
SELECT *|{[DISTINCT] column|expression [alias],...} FROM    table;

Note:
  • SELECT identifies the columns to be displayed
  • FROM identifies the table containing those columns
SELECT is a list of one or more columns 
*   selects all columns
DISTINCT suppresses duplicates
column|expression selects the named column or the expression
alias         gives selected columns different headings
FROM table specifies the table containing the columns
A clause is a part of a SQL statement. For example, SELECT net_id, last_name, ... is a clause.
A statement is a combination of two or more clauses. For example, SELECT * FROM TABLE is a SQL statement.
Writing SQL Statements:
Using the following simple rules and guidelines, you can construct valid statements that are both easy to read and easy to edit:
SQL statements are not case-sensitive (unless indicated).
SQL statements can be entered on one or many lines. 
Keywords cannot be split across lines or abbreviated.
Clauses are usually placed on separate lines for readability and ease of editing.
Indents should be used to make code more readable.
Keywords typically are entered in uppercase; all other words, such as table names and columns, are entered in lowercase.
For example, the following SQL statement (like the example in the slide) displays all columns and all rows of the PEOPLES table:
SELECT  people_id, country_name, location_id FROM    peoples;

 <<Back                        Next >>          

More Useful Software Free Download.


No comments:

Post a Comment