SQL stands for Structured Query Language. In the ever-evolving world of data, SQL stands tall as the standard language for storing, manipulating, and retrieving data in databases. 

SQL is an ANSI (American National Standards Institute) standard, but there are many different versions of the SQL language.

Whether you’re a seasoned software developer, a diligent database administrator, a curious data analyst, or an aspiring data scientist, harnessing the power of SQL is essential for unlocking the insights hidden within your data.

There are different dialects such as :

  • MS SQL Server using T-SQL,
  • Oracle using PL/SQL,
  • MS Access version of SQL is called JET SQL (native format).

Why go for SQL?

  • SQL allows users to execute queries against a database.
  • SQL allows the creation, retrieval, and manipulation of data in the database by using queries.
  • SQL allows both drop and delete functions.
  • SQL can create views and stored procedures in a database.
  • SQL enables seamless integration into various languages through modules, libraries, & pre-compilers.

Let’s understand the mechanism

When executing SQL commands for any RDBMS, the system determines the most efficient way to fulfill the request, and the SQL engine decides how to interpret the task.

Let’s illustrate this with a Diagram

What are the SQL Commands?

The standard SQL commands for interacting with relational databases include CREATE, SELECT, INSERT, UPDATE, DELETE, DROP, and TRUNCATE. These commands can be categorized into different groups based on their functionality.

There are four types of commands in SQL:

  • DDL (Data Definition Language): This includes commands used to create and modify the structure of database objects, such as tables, views, schemas, indexes, etc.”
CommandDescription
CreateTo create a new table, a View of a new table.
AlterDeletes an entire table, a view of a table, or other objects in the database.
DropDeletes an entire table, a view of a table or other objects in the database.
TruncateDelete the elements of a table instead of entire table.
  • DML (Data Manipulation Language) is a computer programming language, used for adding, deleting, and modifying data in a database.
CommandDescription
SelectRetrieves certain records from one or more tables.
InsertWith this command we creates a records.
UpdateTo update any existing records.
DeleteDeletes records
  • DCL (Data Control Language) is a computer programming language, used to control access to data stored in a Data Base.
CommandDescription
GrantGrants a user access privileges.
RevokeRevokes previously granted access privileges from a user.

  • TCL (Transactional Control Language) is a computer programming language which is used to control access to data stored in a Data Base.
CommandDescription
CommitUsed to permanently save all changes made in the current transaction
RollbackTo undo changes that have been made in the current transaction.
SavepointThis command creates points within a transaction to which you can later roll back. It allows for partial rollbacks and more complex transaction control.

Let’s Learn more about SQL

Section 1: Select Statement

SELECT Statement – Demonstrate how to retrieve data from a single table using the basic form of the SELECT statement.

SYNTAX

Here’s a basic syntax for the SELECT statement:

SELECT column1, column2, …FROM table_name; 

1. Retrieve all columns from a table:

2. Retrieve specific columns from a table:

3. Retrieve data with a condition:

Section 2: Filtering Data

1. WHERE Clause: Focuses on filtering data based on specified conditions.

2. DISTINCT: Demonstrates how to eliminate duplicate entries from query results.

3. Comparison Operators: Covers the use of operators such as ‘>’, ‘<‘, ‘=’, ‘!=’ to form conditions in the WHERE clause.

4. LIMIT: Teaches how to restrict the number of rows a query returns using the LIMIT and OFFSET clauses.

5. FETCH: Guides on how to skip a set number of rows before returning rows in a result set.

6. Logical Operators : Introduces logical operators and explains their use in assessing the truth of conditions.

7. AND Operator: Teaches how to combine multiple Boolean expressions with the AND operator.

8. OR Operator: Demonstrates the combination of multiple Boolean expressions with the OR operator.

9. BETWEEN Operator: Guides on selecting data within a specified range using BETWEEN.

10. IN Operator: Shows how to check if a value exists within a list with the IN operator.

11. LIKE Operator: Explains querying data based on specific patterns.

12. IS NULL Operator: Introduces the concept of NULL and how to check for NULL values.

13. NOT Operator: Demonstrates inverting a Boolean expression with the NOT operator.

Leave a Reply

Your email address will not be published. Required fields are marked *