SQL is a declarative language, meaning that it is used to describe what data should be retrieved or manipulated, rather than how to retrieve or manipulate it. SQL statements can be broken down into several categories, including data definition language (DDL), data manipulation language (DML), data control language (DCL), and transaction control language (TCL).
DDL statements are used to create, modify, and delete database objects such as tables, indexes, and views. The basic syntax for creating a table in SQL is as follows:
CREATE TABLE table_name (
column1 datatype constraint,
column2 datatype constraint,
...
columnN datatype constraint
);
DML statements are used to retrieve, insert, update, and delete data in a table. The basic syntax for inserting data into a table in SQL is as follows:
INSERT INTO table_name (column1, column2, ..., columnN)
VALUES (value1, value2, ..., valueN);
DCL statements are used to control the access to data in the database. The basic syntax for granting access to a user in SQL is as follows:
GRANT permission_type ON object_name TO user_name;
TCL statements are used to manage transactions in a database. The basic syntax for starting a transaction in SQL is as follows:
BEGIN TRANSACTION;
SQL also supports several operators that can be used in conjunction with its statements to filter, sort, and aggregate data. Some of the commonly used operators include the WHERE clause, which is used to filter rows based on a condition, the ORDER BY clause, which is used to sort rows based on one or more columns, and the GROUP BY clause, which is used to group rows based on one or more columns.
In summary, SQL is a powerful language that is used to manage and manipulate relational databases. Its syntax is relatively simple, and its declarative nature makes it easy to learn and use. By mastering SQL syntax, developers and data analysts can effectively manage and manipulate data, which is essential for developing effective software applications and making data-driven decisions.
Database Tables
In the context of relational databases, a table is a collection of related data that is organized into rows and columns. Tables are used to store data in a structured way that allows for efficient querying, filtering, and sorting of data. Each table in a database has a unique name that identifies it and can be used to reference it in SQL queries.
Tables are created using the SQL Data Definition Language (DDL) statements. When creating a table, it is necessary to specify the table name, the names and data types of the columns, and any constraints that should be applied to the data in the table. Some common constraints include PRIMARY KEY, UNIQUE, NOT NULL, and CHECK constraints.
Once a table has been created, data can be inserted into it using SQL Data Manipulation Language (DML) statements. The INSERT statement is used to insert new rows into a table, and the UPDATE statement is used to modify existing rows. The DELETE statement is used to remove rows from a table.
Tables can be linked to other tables through relationships, which are established using foreign keys. A foreign key is a column in one table that refers to the primary key of another table. This allows for data to be related and joined across multiple tables.
One important aspect of table design is normalization. Normalization is the process of organizing data in a database to reduce redundancy and dependency. This helps to ensure data integrity and improves the efficiency of data retrieval. There are several normal forms, each with increasing levels of normalization.
Read More:- Introduction to SQL
In summary, tables are an essential component of relational databases, providing a structured way to store and organize data. They are created using DDL statements and can be linked to other tables through relationships. Normalization is an important aspect of table design, helping to improve data integrity and retrieval efficiency.
A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data.
In this tutorial we will use the well-known Northwind sample database (included in MS Access and MS SQL Server).
Below is a selection from the "Customers" table:

The table above contains five records (one for each customer) and seven columns (CustomerID, CustomerName, ContactName, Address, City, PostalCode, and Country).
SQL Statements
SELECT statements are used to retrieve data from one or more tables. They can be customized with WHERE clauses to filter the results based on specific criteria. Aggregate functions like SUM, COUNT, AVG, and MAX can also be used to perform calculations on data within the SELECT statement.
INSERT statements are used to add new rows of data into a table. They require the table name and column names to be specified along with the values to be inserted into those columns.
UPDATE statements are used to modify existing data in a table. They require the table name and columns to be updated along with the new values.
DELETE statements are used to remove rows of data from a table. They require the table name and a WHERE clause to specify which rows should be deleted.
JOIN statements are used to combine rows from two or more tables based on a related column. There are different types of joins, including INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN, each with a different way of handling unmatched rows between tables.
Overall, SQL statements are essential tools for working with databases and allow for efficient and powerful data manipulation and analysis.
Most of the actions you need to perform on a database are done with SQL statements.
The following SQL statement selects all the records in the "Customers" table:
Example

In this tutorial we will teach you all about the different SQL statements.
Keep in Mind That...
Semicolon after SQL Statements?
Some database systems require a semicolon at the end of each SQL statement.
Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.
In this tutorial, we will use semicolon at the end of each SQL statement.
Some of The Most Important SQL Commands
In summary, tables are an essential component of relational databases, providing a structured way to store and organize data. They are created using DDL statements and can be linked to other tables through relationships. Normalization is an important aspect of table design, helping to improve data integrity and retrieval efficiency.
A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data.
In this tutorial we will use the well-known Northwind sample database (included in MS Access and MS SQL Server).
Below is a selection from the "Customers" table:

The table above contains five records (one for each customer) and seven columns (CustomerID, CustomerName, ContactName, Address, City, PostalCode, and Country).
SQL Statements
SELECT statements are used to retrieve data from one or more tables. They can be customized with WHERE clauses to filter the results based on specific criteria. Aggregate functions like SUM, COUNT, AVG, and MAX can also be used to perform calculations on data within the SELECT statement.
INSERT statements are used to add new rows of data into a table. They require the table name and column names to be specified along with the values to be inserted into those columns.
UPDATE statements are used to modify existing data in a table. They require the table name and columns to be updated along with the new values.
DELETE statements are used to remove rows of data from a table. They require the table name and a WHERE clause to specify which rows should be deleted.
JOIN statements are used to combine rows from two or more tables based on a related column. There are different types of joins, including INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN, each with a different way of handling unmatched rows between tables.
Overall, SQL statements are essential tools for working with databases and allow for efficient and powerful data manipulation and analysis.
Most of the actions you need to perform on a database are done with SQL statements.
The following SQL statement selects all the records in the "Customers" table:
Example

In this tutorial we will teach you all about the different SQL statements.
Keep in Mind That...
- SQL keywords are NOT case sensitive: select is the same as SELECT
Semicolon after SQL Statements?
Some database systems require a semicolon at the end of each SQL statement.
Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.
In this tutorial, we will use semicolon at the end of each SQL statement.
Some of The Most Important SQL Commands
- SELECT - extracts data from a database
- UPDATE - updates data in a database
- DELETE - deletes data from a database
- INSERT INTO - inserts new data into a database
- CREATE DATABASE - creates a new database
- ALTER DATABASE - modifies a database
- CREATE TABLE - creates a new table
- ALTER TABLE - modifies a table
- DROP TABLE - deletes a table
- CREATE INDEX - creates an index (search key)
- DROP INDEX - deletes an index