Oracle SQL Tutorials – Chapter 1 (Part 2 of 3)

SELECT Statement

  • Selection : SQL statements are being used to returning the selected lines from related tables.
  • Projection : SQL’s projection ability is being used to returning the selected columns from related tables.
  • Join : SQL’s join ability is being used to display selected data from two diffirent tables in one table.

 

SELECT STATEMENT SYNTAX

  • SELECT *|{[DISTINCT] column|expression [alias],…} FROM table;
  • SELECT : Determines which columns are displayed.
  • FROM : Identifies tables with specified columns

 

ORALCE HR SCHEMA & TABLES

  • In this document, tables of the Oracle HR (Human Resources) Schema will be used as example.If you check ‘add sample schema’ box while creating database, this schema will be added your database as sample schema.

hr schema oracle ile ilgili görsel sonucu

 

SELECT ALL COLUMNS OF A TABLE

  • Let’s list all the employees.

SELECT * FROM hr.employees;

 

SELECT SPECIFIED COLUMNS OF A TABLE

  • Let’s list name, surname, salary and hire date of all employees.

SELECT first_name, last_name, salary, hire_date FROM hr.employees;

 

GIVE ALIAS TO COLUMNS

  • Aliases allow to rename the column.
  • Calculations get easier.
  • It’s written after the column name.
  • ‘AS’ statement can be written between column name and alias.
  • If the alias contains special characters like “ %, $, # ”, it must be written between double quotes.

 

  • Let’s list the name, surname, salary and hire date of the employees with the aliases.

SELECT first_name NAME, last_name SURNAME , salary “SALARY”,hire_date as “Hire Date” FROM hr.employees;

 

You can continue to read from this link ;

https://ittutorial.org/2019/04/02/oracle-sql-tutorials-chapter-1-3/

About ismail tolga can

Leave a Reply

Your email address will not be published. Required fields are marked *