Lesson 3 Beginner Level
3 of 30 lessons

Basic SQL Syntax

SQL (Structured Query Language) follows a specific structure to perform operations such as retrieving, inserting, updating, and deleting data in a database. Knowing the correct syntax is essential to writing valid queries that Oracle can interpret.

Understanding SQL Syntax

SQL (Structured Query Language) follows a specific structure to perform operations such as retrieving, inserting, updating, and deleting data in a database. Knowing the correct syntax is essential to writing valid queries that Oracle can interpret.

General SQL Syntax

SELECT column1, column2
FROM table_name
WHERE condition;

Here's a breakdown:

  • SELECT — specifies the columns you want to retrieve
  • FROM — identifies the table to query
  • WHERE — (optional) filters the results based on a condition

Example

SELECT first_name, last_name
FROM employees
WHERE department_id = 90;

This query fetches the first and last names of employees who work in department 90.

Practice Task

  • Write a SQL query to retrieve all columns from the departments table.
  • Try writing a query that selects job_id and salary from the employees table.
  • What happens if you forget the FROM clause?