Wednesday, November 27, 2013

Arithmetic Expressions


Arithmetic expressions can be used with SQL statements.

Operator
Description
+
Add
-
Subtract
*
Multiply
/
Divide

Using arithmetic expression in queries
Example
SELECT first_name, salary, salary + 500 FROM   employees;
As result from above query 500 will be added all employees salary and will be shown separately.
First_name
Salary
Salary +500
Kery
400
900
Edy
340
840



Tuesday, November 26, 2013

Basic SELECT Statement

SELECT *|{[DISTINCT] column|expression [alias],...}
FROM    table;

SELECT identifies the columns to be displayed
•FROM identifies the table containing those columns

To SELECT all columns from a particular table, the following command is used.


SELECT * FROM   departments;

To SELECT specific columns, column names should be mentioned as below.


SELECT department_id, location_id FROM   departments;

SQL Statements

•SQL statements are not case-sensitive.
•SQL statements can be on one or more lines.
•Keywords cannot be abbreviated or split across lines.
•Clauses are usually placed on separate lines.
•Indents are used to enhance readability.
•In iSQL*Plus, SQL statements can optionally be terminated by a semicolon (;).
Semicolons are required if you execute multiple SQL statements.
•In SQL*plus, you are required to end each SQL statement with a semicolon (;).



Reference : Oracle docs



Tuesday, February 19, 2013

What is SQL?



     The history of SQL begins in an IBM laboratory in San Jose, California, where SQL was developed in the late 1970s. The language itself is often referred to as "sequel." It was originally developed for IBM's DB2 product.
     SQL stands for Structured Query Language. It is the standart language used for accessing and manipulating data from relational databases. By using SQL a programmer or database administrator can do the followings:
  •          Modify a database's structure
  •          Change system security settings
  •          Add user permissions on databases or tables
  •          Retrieve data from a database
  •          Update the contents of a database
  •          Delete Records from database and Insert records to database
  •          Create new tables, databases, views, stored procedures
  •          Set permissions

    The most commonly used statement in SQL is the SELECT statement (next topic will be about SELECT statement), which allows to retrieve records from one or more tables in database.

References:
Oracle Database SQL Language Reference 11g Release 2 (11.2) E26088-03

Friday, February 15, 2013

Preface



The aim of this blog to teach Oracle SQL and PL/SQL step by step from simple to advanced. Each week we will introduce one topic and discuss related issues.  Also questions by users will be taken in attention and will be answered as soon as possible. Our goal is to teach every single element of SQL and PL/SQL to users in deep and make life easier for Oracle users. Hope you will enjoy ..