Definition under: Definitions

What is Structured Query Language (SQL)?

Structured Query Language, commonly known as SQL, is a standardized programming language used primarily for managing and interacting with relational databases. SQL is designed to be simple and intuitive, with a focus on manipulating structured data. It enables users to perform various operations on the data, such as querying for specific information, organizing and filtering results, and making modifications. 


Dissecting Structured Query Language (SQL)

SQL was developed by Donald D. Chamberlin and Raymond F. Boyce at IBM in the early 1970s. It was initially called SEQUEL (Structured English Query Language), and its main purpose was to manipulate and retrieve data stored in IBM's quasi-relational database management system called System R. The name was later changed to SQL due to a trademark conflict.

In 1986, SQL became a standard of the American National Standards Institute (ANSI), and later in 1987, it was adopted as an international standard by the International Organization for Standardization (ISO).


SQL is used in relational databases, which store data in tables composed of rows and columns. Rows represent individual records, while columns contain specific attributes. Important concepts include primary keys, which uniquely identify records within a table, and foreign keys, which connect tables by referencing another table's primary key. SQL allows users to manipulate and retrieve data, perform operations like querying, inserting, updating, and deleting data, and create or modify table structures.


SQL Components

Components are the building blocks that make up SQL statements and queries. They help to structure and define the logic of the SQL code to interact with and manipulate data within a relational database.

  • Keywords: Reserved words in SQL that have specific meanings and functions. They are used to construct SQL statements and queries. Examples of keywords include SELECT, FROM, WHERE, and ORDER BY. Keywords are generally not case-sensitive but are often written in uppercase for better readability.
  • Identifiers: Used to name database objects such as tables, columns, indexes, and views. They follow specific naming rules, typically starting with a letter or an underscore and containing alphanumeric characters and underscores. Identifiers may be case-sensitive in some database systems.
  • Literals: Literals represent constant values used in SQL queries. They can be of different types, such as numeric literals (e.g., 42), string literals (e.g., 'Hello, World!'), or date and time literals (e.g., '2023-03-17'). These constant values are used as inputs or to compare against column values in queries.
  • Operators: Operators are symbols used to perform specific operations in SQL queries, such as arithmetic, comparison, or concatenation. Examples of operators include +, -, *, /, =, <>, <, >, AND, OR, and ||. They are used to manipulate or compare values in SQL expressions.
  • Expressions: Expressions are combinations of literals, identifiers, and operators that evaluate to a single value. They can be used in various parts of an SQL query, such as in the SELECT clause, WHERE clause, or as an argument to a function. Expressions may perform calculations, manipulate strings, or compare values.
  • Clauses: Clauses are components of SQL statements that perform specific functions. They typically include keywords, identifiers, literals, operators, and expressions. Clauses are used to build SQL statements and define the structure of a query. Common clauses are SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY.


SQL Command Categories

Command Categories refer to the classification of SQL commands based on their primary purpose and functionality within a database management system. The categories help to organize the commands for easier understanding and usage. The main SQL command categories are:


Data Definition Language (DDL)

Used to create, modify, or delete the structure of database objects such as tables, views, indexes, and constraints. These commands do not directly deal with the data within the tables but rather define the structure that holds the data. Examples are:

  • CREATE TABLE: Creates a new table with the specified columns and data types.
  • ALTER TABLE: Modifies the structure of an existing table, such as adding or removing columns, changing data types, or adding constraints.
  • DROP TABLE: Deletes an existing table along with all its data and associated constraints.

Data Manipulation Language (DML)

Used to manage the data within the database, including inserting, updating, and deleting data, as well as querying the data. A few examples of DML commands are:

  • SELECT: Retrieves data from one or more tables based on specified criteria.
  • INSERT: Adds new rows to a table with specified values.
  • UPDATE: Modifies existing data in a table based on specified conditions.
  • DELETE: Removes data from a table based on specified conditions.

Data Control Language (DCL)

Used to manage access control and permissions for database objects, enabling administrators to grant or revoke privileges to specific users or roles. Examples of DCL commands include:

  • GRANT: Gives a user or role specific permissions on a database object, such as SELECT, INSERT, UPDATE, DELETE, or ALTER.
  • REVOKE: Removes previously granted permissions from a user or role on a database object.

Transaction Control Language (TCL)

Manage transactions within a database, ensuring data integrity and consistency. Transactions are a sequence of one or more SQL operations that are executed as a single unit of work. If any part of the transaction fails, the entire transaction is rolled back, and the database is returned to its original state. A few examples of TCL commands include:

  • COMMIT: Saves all changes made during the transaction and ends the transaction.
  • ROLLBACK: Undoes all changes made during the transaction and ends the transaction, reverting the database to its original state.
  • SAVEPOINT: Creates a savepoint within the transaction, allowing for partial rollback if needed.


Recently Added Definitions