0% found this document useful (0 votes)
10 views3 pages

SQL Basics: DDL, DML, TCL Explained

The document provides an overview of SQL (Structured Query Language) and its categories, including DDL (Data Definition Language), DML (Data Manipulation Language), and TCL (Transaction Control Language). It outlines key commands for each category, such as CREATE, INSERT, and COMMIT, along with their functions in managing database structures and data. A summary table is included to highlight common commands and their uses.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

SQL Basics: DDL, DML, TCL Explained

The document provides an overview of SQL (Structured Query Language) and its categories, including DDL (Data Definition Language), DML (Data Manipulation Language), and TCL (Transaction Control Language). It outlines key commands for each category, such as CREATE, INSERT, and COMMIT, along with their functions in managing database structures and data. A summary table is included to highlight common commands and their uses.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

The Chintels School, Kalyanpur

Topic – DBMS (Notes) CLASS: X


Subject – Information Technology(402)
VII

Name: _____________________________________ Roll No: ___________ Date: 28 / 05 / 2025

What is SQL?

SQL = Structured Query Language


It helps us to create, insert, change, and view data in databases.

vvvvvv555vvv
SQL Categories vvvvvvVVvvV
VVXii111111
SQL commands are divided into 3 main types:
XIXIXIxiIX_
Type Full Form What it does _IX_

DDL Data Definition Language Creates or changes database structure

DML Data Manipulation Language Adds or changes data inside tables

TCL Transaction Control Language Manages changes made by DML commands

DDL (Data Definition Language)

These commands define the structure of the database (like creating or deleting tables).

1. CREATE

CREATE TABLE Students (

ID INT,

Name VARCHAR(50),

Age INT,

Grade VARCHAR(5)

);

Creates a new table called Students.

2. ALTER

ALTER TABLE Students ADD Email VARCHAR(100);

Adds a new column Email to the table.

3. DROP

DROP TABLE Students;

Deletes the whole table and all its data.


DML (Data Manipulation Language)

These commands change the data inside the tables.

1. INSERT

INSERT INTO Students (ID, Name, Age, Grade)

VALUES (1, 'Alice', 15, '10A');

Adds a new student.

2. SELECT

SELECT * FROM Students;

Views all student data.

3. UPDATE

UPDATE Students

SET Grade = '10B'

WHERE ID = 1;

Changes the grade of the student with ID 1.

4. DELETE

DELETE FROM Students

WHERE ID = 1;

Deletes the student with ID 1.

TCL (Transaction Control Language)

These commands control transactions (groups of operations done together).

1. COMMIT

COMMIT;

Saves all changes made.

2. ROLLBACK

ROLLBACK;

Cancels the changes if something went wrong.


3. SAVEPOINT

SAVEPOINT Save1;

Sets a "save point" to go back to if needed.

Summary Table

Command Type Common Commands Use

DDL CREATE, ALTER, DROP Change table structure

DML INSERT, SELECT, UPDATE, DELETE Change table data

TCL COMMIT, ROLLBACK, SAVEPOINT Control transactions

Common questions

Powered by AI

SQL commands within DML, such as INSERT, SELECT, UPDATE, and DELETE, ensure efficient data operations by providing clear and systematic ways to manipulate data. INSERT adds records efficiently while maintaining table structure, SELECT retrieves data as needed, UPDATE modifies existing records precisely without disturbing overall structure, and DELETE removes specific records. The use of these commands ensures integrity, minimizes errors, and allows focused operations prompting efficient data handling .

TCL, or Transaction Control Language, ensures data safety and integrity by allowing the grouping of operations to be treated as a single unit - a transaction. Commands like COMMIT save changes made by DML commands permanently in the database, while ROLLBACK undoes those changes if an error occurs, maintaining data integrity. SAVEPOINT allows setting restoration points within a transaction, providing fine-grained control over rollback operations .

COMMIT and ROLLBACK commands are essential in transaction processing as they provide mechanisms for either confirming or negating a sequence of changes made within a transaction. COMMIT finalizes the transaction, making all changes permanent, which is crucial for data consistency and preventing data loss. ROLLBACK, conversely, allows reverting to the previous state if any operations within the transaction fail, ensuring that erroneous changes do not compromise data integrity .

Using 'CREATE TABLE' with specified constraints during database design offers numerous benefits, such as ensuring data integrity and consistency. Constraints such as PRIMARY KEY, UNIQUE, NOT NULL, and FOREIGN KEY enforce rules that prevent invalid data entry, maintain relational integrity, and enforce business logic directly within the schema design. This approach reduces redundancy, enhances query efficiency, and upholds data quality from the outset .

ALTER TABLE is used when modifications to the database schema are needed without affecting existing data structures. For example, adding a new column, such as Email to an existing Students table, or changing a column type. This command allows the integration of new data considerations into existing systems while preserving current records intact, although care must be taken to ensure new columns or changes are compatible with existing data .

It is important to plan the use of the DELETE command carefully because it can permanently remove data from a table. Improperly implementing DELETE without constraints or backup strategies can result in unintended data loss, disrupting operations and analyses. Thorough planning ensures that deletions align with business objectives and retain necessary data integrity, often structured within broader data lifecycle management frameworks .

The command 'SELECT * FROM Students' is significant in database querying as it retrieves all records and their respective fields from the Students table. It provides a straightforward means to view the entirety of data entries, providing a complete snapshot of the table's current state. This is crucial for tasks needing comprehension of all stored data without filtering .

Using DDL commands like DROP TABLE can significantly affect data analysis capabilities by permanently removing data structures, and thereby erasing potential data sources for analysis. Subsequent data insights relying on historical or structural context can be compromised, making careful consideration and backups essential before executing such commands to ensure no irreversible loss impedes data analysis processes .

DDL stands for Data Definition Language and is used to define and modify the structure of database objects such as tables and schemas, using commands like CREATE, ALTER, and DROP. DML, or Data Manipulation Language, is used to manipulate the data within existing tables, with commands such as INSERT, SELECT, UPDATE, and DELETE. While DDL changes the schema or structure, DML operates on the data within that structure .

The SAVEPOINT command addresses the risks posed by long and complex transactions by providing intermediate points for possible rollback, allowing partial transaction undoing if a problem is encountered. This reduces the risk of losing all transactional progress due to error in a later stage and allows finer control over transaction management, enabling developers to isolate issues without discarding total transaction progress .

You might also like