SQL (Structured Query Language) is a standardized programming language used to manage, query, and manipulate relational databases. It enables users to perform operations such as:
- Data Definition (DDL): Creating, altering, and deleting database structures (e.g., tables, indexes).
- Data Manipulation (DML): Inserting, updating, deleting, and retrieving data within a database.
- Data Control (DCL): Controlling access to data (e.g., granting or revoking permissions).
- Transaction Control (TCL): Managing database transactions to ensure data consistency (e.g., COMMIT, ROLLBACK).
SQL Commands: DDL, DQL, DML, DCL, and TCL
Structured Query Language (SQL) is the foundation of managing and interacting with relational databases. SQL commands are divided into categories based on their functionality. Understanding these categories is crucial for effective database management and operations.
1. Data Definition Language (DDL)
DDL commands are used to define and modify the structure of database objects such as tables, schemas, and indexes.
Common DDL Commands:
- CREATE: Used to create new database objects.
- ALTER: Used to modify / alter an existing database structure.
- DROP: Deletes database objects permanently.
- TRUNCATE: Removes all records from a table but retains its structure.
2. Data Query Language (DQL)
DQL is focused on querying and retrieving data from the database.
Common DQL Command:
- SELECT: Retrieves data from one or more tables.
3. Data Manipulation Language (DML)
DML commands allow you to manipulate data within database tables.
Common DML Commands:
- INSERT: Add / insert new records to a table.
- UPDATE: Modifies / update existing records in a table.
- DELETE: Removes records from a table.
4. Data Control Language (DCL)
DCL commands manage access permissions and security of the database .
Common DCL Commands:
- GRANT: Assigns specific privileges to users.
- REVOKE: Removes previously granted privileges.
5. Transaction Control Language (TCL)
TCL commands deal with transactions, ensuring the consistency and integrity of the database.
Common TCL Commands:
- COMMIT: Saves all changes made in the current transaction.
ROLLBACK: Undoes changes made in the current transaction.
SAVEPOINT: Creates a point within a transaction to which you can roll back.
SET TRANSACTION: Defines properties for the current transaction.
Important SQL Commands
1.CREATE TABLE: Used to create a new table in a database.
2.ALTER TABLE: Used to modify the structure of an existing table.
3.DROP TABLE: Used to delete an entire table from a database.
4.WHERE: Used to filter rows based on a specified condition.
5.JOIN: Used to Join /combine rows from two or more tables based on a related column between them.
6. ORDER BY: Used to sort the result set in ascending or descending order.
7. SQL OPERATOR: And /OR
9.SQL VIEW
10.STORED PROCEDURE
- Create procedure
- insert procedure
- select procedure
Conclusion on SQL Commands
SQL commands are categorized into distinct groups based on their functionalities, each serving a vital role in database management:
- DDL (Data Definition Language):
Used for defining and modifying the structure of a database. Examples includeCREATE
,ALTER
, andDROP
. DDL commands ensure that databases are well-structured and capable of storing data efficiently. - DQL (Data Query Language):
Focused on retrieving data from the database using queries likeSELECT
. It helps users fetch specific information, analyze data, and derive insights effectively. - DML (Data Manipulation Language):
Enables interaction with data through commands likeINSERT
,UPDATE
, andDELETE
. These commands allow for dynamic data management in databases. - DCL (Data Control Language):
Manages access to data using commands likeGRANT
andREVOKE
. DCL ensures security by defining permissions and roles. - TCL (Transaction Control Language):
Manages the execution of transactions using commands likeCOMMIT
,ROLLBACK
, andSAVEPOINT
. TCL ensures the consistency and reliability of database operations.
Kickstart your career by joining Kaashiv Infotech‘s SQL Server Program, where you will gain expertise in technologies such as Dotnet, Java, SQL, Full Stack Development, and Front End Technologies, while working on real-time projects.
Â