Fundamentals of SQL And Core Concepts of SQL, SQL COMMANDS, DDL,DML,DCL,TCL
Автор: Maithili SoftTech
Загружено: 2025-11-28
Просмотров: 118
Fundamentals of SQL:SQL commands are the keywords and statements used to communicate with a relational database to perform specific tasks, such as creating tables, inserting data, or retrieving information.
1)Data Definition Language (DDL)
2)Data Manipulation Language (DML)
3)Data Query Language (DQL)
4)Data Control Language (DCL)
5)Transaction Control Language (TCL)
The commands are broadly categorized into five main types:
1. Data Definition Language (DDL)
DDL commands are used to define or modify the structure and schema of database objects.
CREATE: Used to create database objects like tables, views, indexes, or entire databases.
Example: CREATE TABLE Students (ID INT PRIMARY KEY, Name VARCHAR(50));
ALTER: Modifies the structure of an existing database object, such as adding or deleting columns in a table.
Example: ALTER TABLE Students ADD Email VARCHAR(100);
DROP: Deletes a database object entirely, including all its data and structure.
Example: DROP TABLE Students;
TRUNCATE: Removes all records from a table quickly, but keeps the table structure intact for future use.
Example: TRUNCATE TABLE Students;
RENAME: Changes the name of an existing database object.
Example: RENAME TABLE StudentsTO Staff;
2. Data Manipulation Language (DML)
DML commands are used to manage data within the schema objects.
INSERT: Adds new rows (records) into a table.
Example: INSERT INTO Students (ID, Name) VALUES (1, 'John Doe');
UPDATE: Modifies existing data within a table based on specified conditions.
Example: UPDATE Students SET Name = 'Jane Smith' WHERE EmployeeID = 1;
DELETE: Removes existing rows from a table based on a condition.
Example: DELETE FROM Students WHERE ID = 1;
3. Data Query Language (DQL)
DQL commands are used to retrieve data from the database. This is primarily the SELECT statement and its clauses.
SELECT: Retrieves data from one or more tables.
Example: SELECT Name, Email FROM Students WHERE id = 1;
WHERE: Filters records based on a specified condition (used with SELECT, UPDATE, and DELETE).
JOIN: Combines rows from two or more tables based on a related column between them.
GROUP BY: Groups rows that have the same values in specified columns, often used with aggregate functions (like COUNT, SUM, AVG).
4. Data Control Language (DCL)
DCL commands manage access and permissions within the database.
GRANT: Gives a user access privileges to the database.
Example: GRANT SELECT ON Students TO user_john;
REVOKE: Removes previously granted permissions from a user.
Example: REVOKE SELECT ON Students FROM user_john;
5. Transaction Control Language (TCL)
TCL commands manage transactions and the changes made by DML statements to ensure data integrity.
COMMIT: Permanently saves the work done during the current transaction.
ROLLBACK: Undoes all changes made during the current transaction if an error occurs or the changes are not desired.
SAVEPOINT: Sets a point within a transaction to which you can later roll back, without rolling back the entire transaction.
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: