HuntExams Academy logo
SQLBeginner#fundamentals

What is SQL?

Answer

Structured Query Language, the standard language for defining, manipulating and querying data in relational databases. It covers DDL (CREATE/ALTER/DROP), DML (INSERT/UPDATE/DELETE), DQL (SELECT), DCL (GRANT/REVOKE) and TCL (COMMIT/ROLLBACK).

Example

CREATE TABLE students (id INT PRIMARY KEY, name VARCHAR(50));
INSERT INTO students VALUES (1, 'Anu');
SELECT * FROM students;

Detailed explanation

SQL stands for Structured Query Language. It is the standard language used to define, retrieve, modify, and control access to data in relational databases. A relational database organises data into tables containing rows and columns: each row represents a record, while each column represents an attribute with a defined data type. SQL is a language, not a database product; MySQL, PostgreSQL, Oracle Database, and Microsoft SQL Server are database management systems that support it, with differences in syntax and features.

SQL statements are commonly grouped by purpose. Data Definition Language (DDL) includes CREATE, ALTER, and DROP for defining or changing database structures. Data Manipulation Language (DML) includes INSERT, UPDATE, and DELETE for changing stored records. SELECT retrieves data and is often taught separately as Data Query Language (DQL), although some classifications include it under DML. Data Control Language (DCL), such as GRANT and REVOKE, manages permissions. Transaction Control Language (TCL), including COMMIT and ROLLBACK, manages transaction outcomes. A transaction groups operations into a unit of work, allowing supported changes to be made permanent or undone before commitment.

For example, CREATE TABLE students (id INT PRIMARY KEY, name VARCHAR(50)); defines a table with two columns. The primary key makes each student's ID unique and prevents it from being NULL. INSERT INTO students (id, name) VALUES (1, 'Anu'); adds a record, and SELECT * FROM students; retrieves all columns from all rows. A WHERE clause can restrict the rows returned, while JOIN combines data from related tables using a matching condition.

SQL is primarily declarative: you describe the result you want rather than write step-by-step instructions for finding it. For a query, the database checks syntax and object references, then its optimiser chooses an execution plan using available information such as indexes and table statistics. The execution engine follows that plan to produce results. Interviewers expect beginners to explain this purpose clearly, distinguish SQL from a database system, and demonstrate a simple statement. Understanding SQL matters because applications depend on reliable data storage, retrieval, and updates.

Key points to remember

  • SQL means Structured Query Language and works with relational data.
  • SQL is a language; MySQL and PostgreSQL are database management systems.
  • DDL defines structures, DML changes records, and SELECT retrieves data.
  • DCL manages permissions, while TCL manages transaction outcomes.
  • SQL is primarily declarative: the database chooses how to execute a query.

Common mistakes candidates make

  • Describing SQL as a database or treating SQL and MySQL as interchangeable names.
  • Saying SQL only retrieves data, ignoring schema definition, updates, permissions, and transactions.
  • Claiming every database supports identical SQL syntax or that DQL is universally classified separately from DML.

Likely follow-up questions

What is the difference between SQL and MySQL?

SQL is a language for working with relational databases. MySQL is a database management system that implements SQL and provides the software needed to store, secure, and access data.

What is the difference between DDL and DML?

DDL defines or changes database structures, for example CREATE TABLE or ALTER TABLE. DML changes records within those structures, for example INSERT, UPDATE, or DELETE.

What do COMMIT and ROLLBACK do?

COMMIT makes the changes in a transaction permanent, while ROLLBACK undoes uncommitted changes supported by the transaction. Their behaviour depends on transaction boundaries, autocommit settings, and the database system.

Interview tip: Start with the full form and purpose, distinguish the language from database products, and use the students example to demonstrate CREATE, INSERT, and SELECT.

Related Interview Questions

1
SQLBeginner#fundamentals

What is the difference between DBMS and RDBMS?

Open
2
SQLBeginner#ddl#dml

Difference between DELETE, TRUNCATE and DROP?

Open
3
SQLIntermediate#joins

Explain all types of JOIN with an example.

Open