Structured (SQL) - Important Questions for Class 12

Chapter 12 - Structured Query Language (SQL)

This page contains important questions on SQL for Class 12 Computer Science. The questions cover definition of SQL, advantages of SQL, data types used in SQL,. These questions are useful for AHSEC/ASSEB Class 12 exam preparation

1. What is a Structured Query Language (SQL)?

Answer :SQL stands for Structured Query Language. It is a language used to create, store, retrieve, modify and manage data in a relational database.

3. What are the advantages of SQL?

Answer: Some of the advantages of SQL are:

  1. Easy to learn
    SQL uses simple English-like commands such as SELECT, INSERT, UPDATE and DELETE making it easy to learn
  2. Easy to retrieve data
    We can quickly search for particular records from a large table.
  3. Easy to modify data
    Existing records can be changed easily using the UPDATE command.
  4. Provides security
    Access to database objects can be controlled using commands such as GRANT and REVOKE.
  5. Reduces manual work
    SQL functions can perform calculations such as total, average, maximum and minimum automatically using aggregate functions

4. What are the categories of SQL?

Answer :SQL commands are divided into the following categories:

  1. DDL (Data Definition Language)
  2. DML (Data Manipulation Language)
  3. DCL (Data Control Language)

 

5. What is DDL?

Answer : DDL stands for Data Definition Language. It is used to create and modify the structure of database objects such as tables, views, indexes, etc.

Important DDL commands include:

  • CREATE
  • ALTER
  • DROP

6.What is a DML?

Answer :DML stands for Data Manipulation Language.It is used to insert, modify, delete and retrieve records from a table. It is used to interact or work with the records stored inside a table.

Important DML commands are:

  • INSERT
  • UPDATE
  • DELETE
  • SELECT

7. What is DCL?

Answer: DCL stands for Data Control Language. It is used to control the access and permissions given to users of databaseThe commonly used DCL commands are:

GRANT

It gives specific privileges to a user.

GRANT SELECT ON STUDENT TO user1;

REVOKE

It removes previously given privileges.

REVOKE SELECT ON STUDENT FROM user1;

8.What are the data types used in SQL?

Answer :The data types used in SQL are: 

  1. integer
  2. numeric
  3. decimal
  4. char
  5. varchar
  6. varchar2
  7. date

 

9. What are constraints?

Answer : A constraint is a rule or condition applied to a column to control the type of data that can be entered into a table. Constraints are needed in order to  maintain the accuracy and reliability of data

10. What are the types of constraints?

Answer :Some of the constraints are:

  • Primary key constraint
  • Unique constraint
  • Not Null constraint
  • Default constraint
  • Check constraint

11. What is primary key constraint?

Answer :A primary key is used to uniquely identify each record in a table.

A primary key:

  • cannot contain duplicate values
  • cannot contain NULL values

12.What is unique constraint?

Answer :The UNIQUE constraint ensures that duplicate values are not entered in a column.

13.What is NOT NULL constraint?

Answer:The NOT NULL constraint does not allow a column to contain a NULL value. NOT NULL means NOT BLANK

14. What is a default constraint?

Answer : The DEFAULT constraint automatically assigns a value when no value is supplied.

15. What is check constraint?

Answer : The CHECK constraint ensures that the value entered satisfies a particular condition.

16. What is the use of drop table command?

Answer :The DROP TABLE command is used to remove a table completely from the database.

17. What is the use of alter table command?

Answer : The ALTER TABLE command is used to modify the structure of an existing table.

It can be used to :

  • Add a new column
  • Change the size of existing column

18. What is the use of select command?

Answer : The SELECT command is used to retrieve information from a table.

19. What is the use of distinct clause?

Answer :DISTINCT is used to display only different or unique values.

20. What is the use of where clause?

Answer : The WHERE clause is used to specify a condition for selecting records.

21. What is the use of between operator?

Answer : The BETWEEN operator is used to select values within a specified range.

22. What is the use of ORDER BY clause?

Answer : The ORDER BY clause is used to arrange the result in ascending or descending order.

23. What is the use of GROUP BY clause?

Answer :The GROUP BY clause is used to arrange rows having the same value into groups.

It is commonly used with aggregate functions such as SUM(), AVG(), COUNT(), MAX() and MIN().

24. What is the use of HAVING clause?

Answer : The HAVING clause is used to apply a condition to groups created by GROUP BY.

25. What are aggregate functions?

Answer :

Aggregate functions perform calculations on a group of values and return a single result.

The important aggregate functions are:

  • SUM()
  • AVG()
  • COUNT()
  • MAX()
  • MIN()

25. What is a join operation?

Answer :In a relational database, information is often stored in more than one table.A join operation is used to combine data from two or more tables

25. What is union?

Answer :The UNION operator is used to combine the results of two SELECT queries into one result.

25. What is cartesian product?

Answer :A Cartesian product combines every row of the first table with every row of the second table.

It can be obtained by writing two tables in the FROM clause without a joining condition.

Example:

SELECT * FROM STUDENT, MARKS;

Scroll to Top