TN Online TestSamacheer Kalvi practice

Structured Query Language (SQL)

This chapter introduces the Structured Query Language (SQL), the standard database tool for managing and manipulating relational databases. Students will learn the various components of SQL, how to create and alter database tables, enforce database integrity constraints, and query data using filter conditions and sorting mechanisms.

Study this chapter

Book Back Questions5 textbook MCQs · solved Additional MCQs15 extra MCQs · solved Practice TestInteractive · instant score Book Back TestTest yourself on the textbook set Additional MCQ TestTest yourself on the extra set Study NotesConcepts & methods Formula SheetAll key formulas

About Structured Query Language (SQL)

Medium ~120 min study

In the modern computing era, data is one of the most valuable resources, requiring secure, efficient, and structured storage. Relational Database Management Systems organize data into tables of rows and columns, but accessing this data requires a specialized communication tool. This chapter exists to teach students the fundamentals of Structured Query Language, which serves as the universal language for interfacing with relational databases.

The chapter systematically connects the conceptual database architecture with practical programming commands. It introduces basic data types and progresses to Data Definition Language for designing database structures, followed by Data Manipulation Language for handling actual records. These foundational blocks lead to Data Query Language, demonstrating how simple commands filter, group, and sort retrieved information into meaningful resources.

For high school board examinations, this chapter holds significant importance, testing both theoretical concepts and practical syntax. Students are frequently asked to define SQL components, explain database constraints, and write specific queries to retrieve or modify data. Mastering these commands is essential for scoring well on both descriptive questions and hands-on laboratory assessments.

What you'll learn

Before you start

Topics covered in this chapter

Database Management and SQL Understanding the fundamental role Structured Query Language plays in managing, accessing, and organizing structured records within Relational Database Management Systems.
Data Definition Language Exploring commands like create, alter, truncate, and drop used to establish, modify, and delete the physical schemas and structures of database tables.
Data Manipulation Language Mastering commands such as insert, update, and delete to add new records, modify existing values, or remove specific rows from database tables.
Integrity Constraints Enforcing database accuracy and consistency through column and table rules, including primary key, unique, check, default, and not null constraints.
Data Query Language Using the select statement to fetch specific subsets of records from one or more database tables using custom filter conditions.
Advanced Filtering and Filtering Clauses Implementing filtering clauses like distinct to eliminate duplicate rows, and where to extract rows that satisfy precise logical conditions.
Data Aggregation and Sorting Utilizing group by to aggregate identical rows, having to filter summarized results, and order by to arrange outputs alphabetically or numerically.
Transaction Control Language Managing database transactions using commit to save changes permanently, rollback to undo mistakes, and savepoint to create temporary recovery markers.

Structured Query Language (SQL) explained

Overview of Structured Query Language

Foundations of Database Querying

Relational Database Management Systems store information inside physical tables consisting of columns and rows. While database systems manage the storage on disk, Structured Query Language serves as the standard tool to interact with these platforms. SQL enables users to create databases, declare schema definitions, and execute actions that bridge the gap between database backends and consumer-facing software applications.

The Core Subdivisions of SQL Commands

SQL is divided into specialized languages designed for distinct administrative duties. Data Definition Language handles structural changes, while Data Manipulation Language handles modifying row records. Data Control Language establishes access privileges, whereas Transactional Control Language coordinates system changes to prevent data corruption. Finally, Data Query Language focuses on retrieving information without altering the database.

Table Definition and Structural Operations

Creating a table involves defining its fields, designating specific data types, and setting storage capacities. DDL commands like CREATE TABLE establish these schemas in the system. When changes are needed later, ALTER TABLE allows administrators to append new columns, delete obsolete attributes, or change data types, while DROP TABLE deletes entire structures when they are no longer required.

Enforcing Integrity with Database Constraints

To ensure database accuracy, administrators apply validation rules called constraints. These are implemented at either the column or table level. A NOT NULL constraint ensures fields always contain values, UNIQUE prevents duplicate entries, and CHECK limits values to a specific range. Most importantly, a PRIMARY KEY uniquely identifies each table record and forbids any null inputs.

Data Manipulation and Record Maintenance

Once structural tables are established, DML commands populate and maintain the actual rows of data. The INSERT command adds fresh records, requiring values to correspond to the table's defined column layout. The UPDATE command revises existing cell values based on matching filter criteria, while the DELETE command removes specific rows permanently from the system without destroying the table structure.

Querying and Filtering Table Data

The SELECT command is the heart of DQL, retrieving specific subsets of records based on logical criteria. Using the WHERE clause with operators like BETWEEN, IN, and logical connectives allows students to target precise rows. To present data clearly, ORDER BY sorts the output, GROUP BY aggregates identical values into summary rows, and HAVING filters those grouped records using group functions.

Control and Transaction Management

Changes made by manipulation commands are temporary until committed to the disk. Transactional Control Language commands manage these active states to keep data safe. The COMMIT command permanently saves pending modifications, while ROLLBACK restores the database to its last saved configuration. Additionally, SAVEPOINT establishes markers inside an active transaction, allowing partial rollbacks to specific progress points.

Common mistakes to avoid

Test yourself on these with the practice test, then check the worked reasoning in the solved MCQs.

Frequently asked questions

What is the difference between SQL and MySQL?

Structured Query Language is the standardized programming language used to interface with and manipulate databases. In contrast, MySQL is an actual relational database management system that uses SQL as its language to store, organize, and retrieve structured data records.

What is the difference between primary key and unique constraint?

Both constraints prevent duplicate entries in a column. However, a table can have only one primary key, which strictly forbids null values. Conversely, a table can support multiple unique constraints, but the columns must be explicitly declared as not null to prevent empty values.

What happens if I run a delete command without a where clause?

If you execute a delete command without specifying a where clause, the system will delete all row records from the target table. While the table's structure and schema will remain intact, all the stored data is lost unless a transaction rollback is performed.

How do delete, truncate, and drop commands differ?

Delete removes rows based on conditions without freeing storage space. Truncate deletes all rows, retains the table structure, and frees up the occupied storage space. Drop removes the entire table structure, columns, and records permanently from the database schema.

When should I use having instead of where in SQL?

Use the where clause to filter individual records before they are grouped. Use the having clause to filter summarized results after grouping is performed, which is necessary when your filter condition contains group functions like count, sum, or average.

What is the purpose of committing a transaction?

When you run data manipulation commands like insert or update, changes are stored temporarily in memory. Committing a transaction permanently writes these modifications to the physical storage disk, making them irreversible and visible to other database users.

How does the rollback command protect database records?

The rollback command allows you to undo temporary data modifications. If you make a mistake, such as executing an incorrect delete statement, rollback restores the database to its last committed state, or to a pre-defined savepoint, preventing permanent data loss.

Last updated 22 August 2026

More chapters in Computer Science

View all
1 Function 2 Data Abstraction 3 Scoping 4 Algorithmic Strategies 5 Python -Variables and Operators 6 Control Structures 7 Python functions 8 Strings and String manipulation 9 Lists, Tuples, Sets and Dictionary 10 Python Classes and objects 11 Database Concepts 13 Python and CSV files 14 Importing C++ programs in Python. 15 Data manipulation through SQL 16 Data visualization using pyplot: line chart, pie chart and bar chart