SQL

Q1. What is SQL?
Answer: SQL stand for Structure Query Language. It can retrieve data from database.

Q2. How to practice SQL?
Answer: To prictisce SQL at first need a database. As like MS Access, MySQL, Oracle, SQL Server etc.

Note: We practice SQL on Oracle Database.

To see installation process click here.

Class 1.

Basic SELECT Statement

There has two keywords in the basic SELECT statement
         1. SELECT
         2. FROM

When we use those keyword they make a statement. That's called a basic SELECT statement. All the statement enclosed by semi-colon (;). In the statement SELECT and FROM are two clues. In front of SELECT clues we use column name and in front of FROM clues use table.

Example:

SELECT employee_id, last_name, hire_date, job_id, salary, department_id
FROM employees;


Here employee_id, last_name, hire_date, job_id, salary, department_id are column name and employees is table name.

Note: Before practice this statement must be connected HR schema which is default user Oracle installation.





Class 2. 

Alias Using
 In SQL statement we can use an alias as a column header.

SELECT employee_id, first_name ||' '|| last_name AS "Name"
 FROM employees;

There Name is an alias of employee name. We also can use "Employee Name". Employee Name contains a space and here also the alias have a combination of letter (Upper & Lower).

No comments:

Post a Comment

ORA-01436: CONNECT BY loop in user data

            SELECT CASE                      WHEN CONNECT_BY_ISLEAF = 1 THEN 0                      WHEN LEVEL = 1 THEN 1                   ...