SQL: What It Is and What It Does

SQL: What It Is and What It Does. Foundational Computer Awareness explanations, examples and explained practice questions for banking and recruitment exam preparation.

By Akhilesh Saini

Learning objectives

Recognize SQL as the main language for relational databases, explain common statement categories, and read simple SELECT, WHERE and ORDER BY examples.

What SQL does

SQL stands for Structured Query Language. It is a declarative language used to define, query and manipulate data in relational databases. Instead of describing each internal step for searching storage, a SQL query normally specifies what result is needed. SQL is a language; software such as PostgreSQL, SQLite, MySQL and SQL Server implements database functions and supports SQL with product-specific differences.

A simple SELECT statement requests data. To see this in a fictional training table named Accounts, consider:

account_idholdertypebalance
A501MiraSavings800
A502RaviCurrent250
A503NoorSavings1200
A504IshaSavings300

The table is educational only; all sample names and balances are invented.

A SQL SELECT query filters fictional account balances at least 500 and sorts result rows descending.
SQL query anatomy and filtered result

Read SQL one clause at a time

SELECT holder, balance
FROM Accounts;

SELECT chooses which columns to return; FROM identifies the source table. This query returns four rows and two columns. It does not update balances.

SELECT holder, balance
FROM Accounts
WHERE type = 'Savings';

WHERE filters rows to the three Savings entries: Mira 800, Noor 1200 and Isha 300. The text 'Savings' is in single quotes because it is a character value in this example.

SELECT holder, balance
FROM Accounts
WHERE balance >= 500
ORDER BY balance DESC;

WHERE keeps balances at least 500, and ORDER BY ... DESC orders the returned rows from highest to lowest balance: Noor 1200, Mira 800. ASC is ascending, and DESC is descending. A table does not promise a particular output order without an appropriate ORDER BY.

SELECT COUNT(*) AS account_count
FROM Accounts;

COUNT(*) counts rows. This example returns 4. In contrast, COUNT(column_name) generally counts non-NULL values of the column, not necessarily every row.

Essential commands by purpose

Statement/keywordIntroductory meaningCategory often used in exams
SELECTRead/query dataDQL (data query language) in many teaching classifications
INSERTAdd rowsDML (data manipulation language)
UPDATEChange rowsDML
DELETERemove selected rowsDML
CREATEDefine an object such as a tableDDL (data definition language)
ALTERChange structureDDL
DROPRemove a database objectDDL
GRANT / REVOKEGrant/revoke permissions where supportedDCL (data control language)
COMMIT / ROLLBACKComplete/undo a transaction when applicableTCL (transaction control language)

DQL, DML, DDL, DCL and TCL are useful teaching groupings; precise classifications and command support vary across textbooks and products. Some texts group SELECT with DML. Do not mistake this variation for a change in what SELECT actually does.

Updating data requires care

UPDATE Accounts
SET balance = 900
WHERE account_id = 'A501';

This illustrative update targets only A501. Without a WHERE condition, an UPDATE can affect all rows in a table. The same caution applies to DELETE. These statements are shown to help you identify SQL, not as instructions for modifying a real financial database. Actual balance changes require controlled transactional systems and business authorization, not casual SQL editing.

Basic comparisons and aggregates

ConceptExampleWhat it means
Equalitytype = 'Savings'Match a value
Greater thanbalance > 500Excludes exactly 500
Greater than/equalbalance >= 500Includes exactly 500
Logical conditiontype = 'Savings' AND balance > 500Both conditions
Matching alternativestype = 'Savings' OR type = 'Current'Either condition
COUNT(*)Number of rowsCount
SUM(balance)Total of valuesSum of balances in this artificial table
AVG(balance)Average of valuesMean of non-NULL values
MAX(balance)Largest valueMaximum
MIN(balance)Smallest valueMinimum

In actual SQL, conditions involving NULL usually need IS NULL / IS NOT NULL rather than = NULL. The way SQL treats unknown values is a topic to recognize, not a requirement to master SQL's full three-valued logic here.

Common confusions and exam traps

  • SQL ≠ a specific DBMS product. SQL is a language; MySQL is a DBMS.
  • SELECT retrieves; INSERT adds; UPDATE modifies; DELETE removes.
  • WHERE filters rows; ORDER BY sorts the returned result.
  • DELETE rows vs DROP table: different operations.
  • COUNT(*) and COUNT(column) can differ when the column contains NULL values.
  • SQL keywords are generally case-insensitive, but names, collations and string comparisons can have product-specific behavior.

Quick revision

  1. SQL means Structured Query Language.
  2. SELECT ... FROM ... WHERE ... is a basic retrieval pattern.
  3. ORDER BY ... DESC sorts highest-to-lowest for numeric values.
  4. DDL concerns structure; DML concerns data changes; DCL/TCL concern permissions/transactions.
  5. Avoid assuming a row order without an explicit sorting clause.

Practice questions — CA-08-04

1. What is the full form of SQL?
A. Standard Quality Listing
B. Structured Query Language
C. System Quick Link
D. Sequential Queue Logic

2. Which SQL command primarily retrieves data?
A. INSERT
B. DELETE
C. SELECT
D. DROP

3. Which clause selects only rows matching a condition?
A. WHERE
B. ORDER BY
C. FROM only
D. AS only

4. What does ORDER BY balance DESC do?
A. Permanently delete balances
B. Group duplicate values
C. Encrypt the balance column
D. Display results ordered from higher to lower balances

5. Which command adds a new row?
A. ALTER
B. INSERT
C. SELECT
D. GRANT

6. Which command changes values in existing rows?
A. CREATE
B. DROP
C. UPDATE
D. ORDER BY

7. COUNT(*) on the four-row Accounts teaching table returns:
A. 4
B. 3
C. 1
D. 1200

8. In the teaching table, which holders satisfy balance >= 500?
A. Ravi and Isha
B. Only Ravi
C. All four holders
D. Mira and Noor

9. Which pair typically belongs to DDL?
A. SELECT and WHERE
B. CREATE and ALTER
C. INSERT and UPDATE
D. COMMIT and ROLLBACK

10. Which statement best distinguishes DELETE from DROP?
A. They are always the same command
B. DROP only sorts rows
C. DELETE removes selected rows; DROP removes a database object
D. DELETE must add a column

11. If SQL SELECT has no ORDER BY, which statement is safest?
A. No particular row order is guaranteed
B. Rows always appear newest first
C. Rows must be alphabetical
D. The query always fails

12. Which assertion about SQL and MySQL is correct?
A. Both are hardware devices
B. SQL is a database file extension
C. MySQL is a programming keyboard
D. SQL is a language and MySQL is a DBMS product

Answers and explanations — CA-08-04

1. B — Structured Query Language. SQL is the language used to define, query and modify data in many relational database systems.

2. C — SELECT. SELECT requests result rows/columns and does not itself alter the stored data.

3. A — WHERE. WHERE filters rows according to a predicate, for example type = Savings.

4. D — Display results ordered from higher to lower balances. DESC means descending ordering in the query result, not an update to the stored values.

5. B — INSERT. INSERT adds rows; SELECT retrieves, ALTER changes structure and GRANT concerns privileges.

6. C — UPDATE. UPDATE changes existing values, and an appropriate WHERE clause narrows which rows are targeted.

7. A — 4. The example table has four rows, and COUNT(*) counts rows rather than summing balances.

8. D — Mira and Noor. Mira has 800 and Noor has 1200; Ravi 250 and Isha 300 are below 500.

9. B — CREATE and ALTER. CREATE and ALTER define/change database structure and are common data-definition commands.

10. C — DELETE removes selected rows; DROP removes a database object. DELETE is a data-change statement, whereas DROP removes an object such as a table.

11. A — No particular row order is guaranteed. Relational query results do not guarantee a specific order without an explicit applicable ORDER BY.

12. D — SQL is a language and MySQL is a DBMS product. SQL names the language; MySQL names one database software product that supports SQL.