Structured Query Language (SQL) is the cornerstone of database operations. Whether you're building, modifying, or securing your database, SQL commands make it all happen.
DDL(Data Define Language)
- DDL is a subset of SQL used to define, modify, or remove database structures such as tables, schemas, and indexes. These commands deal with the structure of the database, not the data inside.
1.CREATE
Creates a new table, view, index, or database object.
2.ALTER
Modifies an existing database object, such as adding/removing columns.
3.DROP
Deletes an existing database object permanently.
4.TRUNCATE
Removes all records from a table, but not the table itself (faster than DELETE).
5.RENAME
Changes the name of an existing database object.
DML (Data Manipulation Language)
- DML is a subset of SQL used to manage and manipulate the data stored in database tables. It allows operations like inserting, updating, deleting, and merging records.
1.INSERT
Adds new records (rows) into a table.
2.UPDATE
Modifies existing records in a table.
3.DELETE
Removes specific records from a table based on a condition.
4.MERGE
Performs insert or update operations based on matching conditions
TCL (Transaction Control Language)
- TCL is a subset of SQL used to manage transactions in a database. It ensures data integrity by controlling how changes are committed or rolled back.
1.COMMIT
Saves all changes made in the current transaction permanently.
2.ROLLBACK
Undoes changes made in the current transaction.
3.SAVEPOINT
Sets a point within a transaction to which you can roll back.
DCL (Data Control Language)
- DCL is a subset of SQL used to control access and permissions on database objects. It deals with granting and revoking user privileges.
1.GRANT
Gives a user permission to perform specific actions on database objects.
2.REVOKE
Removes previously granted permissions from a user.
DQL (Data Query Language)
- DQL is a subset of SQL used to query and retrieve data from database tables. It typically involves the SELECT statement, which allows you to filter, sort, and display data.
1.SELECT
Retrieves data from one or more tables based on conditions.
Conclusion
SQL commands are essential tools for managing, structuring, querying, securing, and maintaining data in relational databases, empowering developers to build efficient, reliable, and scalable applications across a wide range of industries and platforms.
Top comments (0)