2/4/11

SQL : Structured Query Language (basics)

SQL stands for Structured Query Language is a database computer language used for managing data when used with application  in a Relational Database Management System (RDBMS).

There are many database software available which used the same query language. Some of them are Oracle, My SQL, DB2 etc. 
As the name suggest Structures Query language so it uses QUERY for retrieval of data from the database, and that query has a structure which is same for all databases software.


SQL has statements, which are used as query :


Query
Used For
Select
Data Retrieval
Insert
Update
Delete
Merge
Data Manipulation Language (DML)
Create
Alter
Drop
Renance
Truncate
Data Definition Language (DDL)
Commit
Rollback
Savepoint
Transaction Control
Grant
Revoke
Data Control Language (DCL)

Select Statement :

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

1. SELECT identifies what columns
2. FROM identifies which table

In SQL you can also perform Arithmetic Operations, but we have to keep in mind the operator are executed that is the OPERATOR PRECEDENCE :

1. * (multiplication)
2. / (division)
3. + (addition)
4. - (subtraction)


Like programming languages here also we can do CONCATENATION, by using the concatenation operator ie '||'

Ex.
SELECT last_name||job_id AS "Employees" FROM employees;

Now for retrieving of data we can also use a where condition, which helps us to make our search more accurate.

SYNTAX :

SELECT *|{[DISTINCT] column|expression [alias],...}
FROM table
[WHERE condition(s)];

*The WHERE clause follows the FROM clause.

Ex.

SELECT employee_id, last_name, job_id, department_id
FROM employees
WHERE department_id = 90 ;

These are some of the basic operations that you can perform for retrieval of data from the database using condition if you want to.


SHARE THIS POST: