SQL : Key Features, Commands & Practical Use Cases |Data Analytics | Belayet Hossain
SQL (Structured Query Language) is a standard programming language specifically designed for managing and manipulating relational databases.
Key Features of SQL
Common SQL Commands
SQL is broken down into several types of commands, each serving a different purpose:
1. Data Definition Language (DDL):
→ CREATE: Creates a new table, view, or database.
→ ALTER: Modifies the structure of an existing table (e.g., adding or removing columns).
→ DROP: Deletes a table or database permanently.
→ TRUNCATE: Removes all rows from a table without deleting the table itself.
→ RENAME: Changes the name of a table or a column in the database.
2. Data Manipulation Language (DML):
→ INSERT: Adds new data into a table.
→ UPDATE: Modifies existing data in a table.
→ DELETE: Removes data from a table.
3. Data Control Language (DCL):
→ GRANT: Gives permissions to users.
→ REVOKE: Removes permissions from users.
4. Transaction Control Language (TCL):
→ COMMIT: Saves changes to the database permanently.
→ ROLLBACK: Undoes changes to the last saved state.
→SAVEPOINT: Sets a temporary point in a transaction to which you can roll back.
Recommended by LinkedIn
5. Data Query Language (DQL):
→ SELECT: Retrieves specific data from one or more tables.
Practical SQL Use Cases for Data Analysis
1. Filtering Data with SELECT and WHERE
2. Aggregating Data with GROUP BY
3. Joining Data with JOIN
4. Sorting and Limiting Results with ORDER BY and LIMIT
5. Updating Data with UPDATE
Real-World Example
Consider a sales database with tables for Customers, Products, and Orders:
→ Use JOIN to link Orders with Products to get order quantity and product price.
→ Multiply quantity by price to calculate revenue per product.
→ Use GROUP BY on the product and sum the revenue.
→ Sort results in descending order and use LIMIT to get the top 5 products.
Summary
SQL is essential for working with relational databases and is foundational for tasks like querying, transforming, and analyzing data. It provides a consistent, structured way to handle data, enabling businesses to make data-driven decisions and gain insights efficiently.
#SQL #daatanalytics #commands #data