Loading

Understanding SQL Syntax

SQL (Structured Query Language) is a powerful language used for interacting with databases. It follows a defined syntax - a set of rules and guidelines standardized by ISO and ANSI - to ensure consistent communication with the database system.



Key Points About SQL Syntax

  1. Case Insensitivity

    • SQL is not case-sensitive.

    • Keywords like SELECTFROM, and WHERE can be written in uppercase or lowercase.

    • Writing SQL keywords in uppercase improves readability.

  2. Line Independence

    • SQL statements can be written across one or multiple lines.

    • SQL does not care about line breaks but uses a semicolon ( ; ) to end a statement.

  3. SQL Keywords and Statements

    • SQL statements always begin with an SQL keyword such as SELECT, INSERT, UPDATE, etc.

    • Most actions on a database—such as querying, inserting, updating, or deleting—are performed using SQL statements.

  4. Semicolon Usage

    • A semicolon is used to end a SQL statement.

    • It also separates multiple statements in a single execution block.



Common SQL Statement Example

SELECT column_name FROM table_name;

This statement tells the database to fetch the value from column_name in the table called table_name.

  • Each SQL statement begins with any of the SQL keywords and ends with the semicolon(;).
  • The semicolon is used for separating the multiple SQL statements which are going to execute in the same call.


Two-Minute Drill – SQL Syntax Recap

  • SQL syntax follows ISO and ANSI standards.

  • Keywords can be written in any case but uppercase is preferred for better readability.

  • Statements can be split across multiple lines.

  • Each statement ends with a semicolon.

  • Almost every action in a database is done using SQL statements.

  • SQL statements define what data to access and what operation to perform.