What is SQL primarily used for in the context of relational databases?

2024

What is SQL primarily used for in the context of relational databases?

  1. A.

    To design user interfaces

  2. B.

    To create and manipulate databases

  3. C.

    To display data on web pages

  4. D.

    To format printed reports

Attempted by 2088 students.

Show answer & explanation

Correct answer: B

Primary purpose: SQL is used to create, query, update, and manage relational databases.

  • Define and modify database structure (Data Definition Language): CREATE, ALTER, DROP.

  • Insert, update, delete, and retrieve data (Data Manipulation Language): INSERT, UPDATE, DELETE, SELECT.

  • Manage access and permissions (Data Control Language) and handle transactions (Transaction Control Language).

Example commands:

  1. SELECT to query data, e.g., SELECT name FROM employees WHERE department = 'Sales';

  2. INSERT to add rows, e.g., INSERT INTO employees (name, department) VALUES ('Alex', 'Sales');

  3. CREATE TABLE to define tables and schema.

Note: While SQL provides the data, displaying or formatting that data for web pages or printed reports is handled by application code or reporting tools.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor