Introduction to SQL

INF2603 - Databases I · Structured Query Language (SQL)

Introduction to SQL

Structured Query Language (SQL) is a standard programming language used for managing and manipulating relational databases. SQL allows you to perform various operations on the data stored in a database, such as querying data, updating records, and creating or deleting tables.

What is SQL?

SQL is a domain-specific language that is designed for managing data in a relational database management system (RDBMS). It provides a way to interact with the database by writing commands that the database can understand.

Remember: SQL is not case-sensitive, but it is common practice to write SQL keywords in uppercase.

Basic Structure of SQL Commands

SQL commands are typically structured in a specific way. The basic structure of an SQL command includes the following components:

  • Keywords: These are the reserved words in SQL, such as SELECT, INSERT, UPDATE, DELETE, and WHERE.
  • Identifiers: These refer to the names of database objects, such as tables and columns.
  • Expressions: These are combinations of values, operators, and functions that SQL can evaluate.
  • Clauses: These are components of SQL statements that define specific conditions or actions.

Example of a Basic SQL Query

Let us consider a simple example. Suppose you have a table named Employees with the following columns: EmployeeID, Name, Position, and Salary.

The SQL query to select all records from the Employees table would look like this:

SELECT * FROM Employees;

This command does the following:

  • SELECT: This keyword specifies which columns to retrieve.
  • *: This symbol means