View video tutorial

ORACLE Query Syntax

ORACLE

An Oracle query is a command used to retrieve, modify, or manipulate data stored in an Oracle database, written in SQL (Structured Query Language) and is a global standard for accessing relational databases.

Oracle SQL Query


➔ An Oracle SQL query is a Structured Query Language (SQL) statement used to retrieve, modify, or manipulate data within an Oracle database.

➔ Most of the time it is a SELECT statement that is used to fetch specific rows and columns from a database table with or without a filter clause.

Basic elements of an Oracle query


SELECT: Specifies which columns or expressions to retrieve.

FROM: Identifies which table containing the data.

WHERE: (Optional) Filters records based on specific conditions applied on the query.

GROUP BY: (Optional) This clause is used to divide a result set into subgroups that have matching values ​​in one or more columns.

HAVING: (Optional) This clause is used to filter groups of data.

ORDER BY: (Optional) This clause is used to sort the records in the result set in ascending or descending order.

Common Example of Oracle Query

Syntax (Simple Selection)

SELECT * FROM myemployees;

This query retrieves all columns and available rows from the table.

Syntax (Apply filters or conditions on the selection)

SELECT FIRST_NAME, SALARY FROM myemployees WHERE SALARY > 25000;

This query retrieves all available rows for employees where salary is over 25,000

Syntax (Retrieving top N rows)

SELECT * FROM myemployees 
FETCH FIRST 10 ROWS ONLY; 

To limit the number of results, this query retrieves all columns and only 10 rows from the table.

Querying from multiple tables using joins.


➔ Combines data from two or more tables based on related columns using INNER JOIN, LEFT JOIN, SELF JOIN, etc. and retrieves it through a select query.

Query execution tools for learning or practicing SQL in Oracle.


➔ Oracle SQL Developer: A desktop-based integrated development environment (IDE) for database management, table creation, query execution, and more. This is a graphical tool provided by Oracle to help Oracle developers manage everything easily and graphically.

➔ Oracle FreeSQL: A browser-based online platform for practicing SQL without local installation. This is useful for temporary and quick testing of queries, or when a local installation is not possible to learn Oracle.

Freesql is an online platform for learning Oracle SQL.

freesql online

➔ SQL*Plus: A command-line utility for interactng directly with databases on a local Oracle database server. This option is best for those who want to learn Oracle from scratch and in depth. It is recommended to create a local learning environment by installing Oracle Server on your machine and doing any exercises to gain hands-on experience.