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:

Related Posts:

  • Indexes in Teradata Teradata as we all know is a Relational Database Management System (RDBMS) for the world's largest commercial databases. It is the market leader in  Data Warehousing. Its architecture is so designed that it takes advan… Read More
  • Conditional Statements in PL/SQL Conditional Statements in PL/SQL are same as conditional statements available in java, c++, c or any other language. PL/SQL allows processing of data using the following conditional statements:     * IF  … Read More
  • Iterative Statements in PL/SQL In the last post on PL/SQL, we had seen Conditional Statements and how they can be used. Today we will be learning about Iterative Statements in PL/SQL. As we all know the types of Iterative statements that are there in… Read More
  • Primary Index Choice Criteria We have already seen Tutorial Primary Index and we have understood how Primary Index work and how they us in maximizing performance. Today we will be learning on how to choose Primary Index/Indexes in a given table. … Read More
  • Tutorial on Primary Index in Teradata Last tutorial was on Indexes in Teradata in which we covered Primary Index, Secondary Index and Join Index. What we saw was just a summary of all the Indexes. This tutorial will help you in understanding Primary Index in… Read More