0% found this document useful (0 votes)
6 views10 pages

Sql Q&A

The document provides a comprehensive overview of SQL concepts, including definitions and purposes of various SQL components such as primary keys, foreign keys, indexes, joins, and aggregate functions. It explains the functionality of SQL statements like SELECT, UPDATE, DELETE, and their clauses, as well as specialized functions like COALESCE, LEAD, and LAG. Additionally, it distinguishes between different types of joins and outlines the roles of transactions and stored procedures in database management.

Uploaded by

challavikki8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views10 pages

Sql Q&A

The document provides a comprehensive overview of SQL concepts, including definitions and purposes of various SQL components such as primary keys, foreign keys, indexes, joins, and aggregate functions. It explains the functionality of SQL statements like SELECT, UPDATE, DELETE, and their clauses, as well as specialized functions like COALESCE, LEAD, and LAG. Additionally, it distinguishes between different types of joins and outlines the roles of transactions and stored procedures in database management.

Uploaded by

challavikki8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Structured Query

Language
Question

1. What is SQL?

➡SQL (Structured Query Language) is a programming language used


for managing relational databases. It allows users to store,
manipulate, and retrieve data from databases

er
2. What is a primary key?

d
➡A primary key is a column or a set of columns that uniquely

o
identifies each record in a table. It ensures data integrity and allows

C
e cient retrieval of data.

b
3. What is a composite key?

e
➡ A composite key is a primary key composed of two or more

W
columns. Together, these columns uniquely identify each record in a

y
table.

B
4. What is a foreign key?

ch
➡A foreign key is a column or a set of columns in a table that refers
to the primary key of another table. It establishes a relationship

Te
between the two tables

5. What is an index?

➡An index is a database structure that improves the speed of data


retrieval operations on database tables. It allows faster searching,
sorting, and filtering of data.

6. What is a clustered index?

➡ A clustered index determines the physical order of data in a table.


Each table can have only one clustered index, and it is generally
created on the primary key column(s).

@techbywebcoder
7.What is a non-clustered index

➡a. A non-clustered index is a separate structure from the table that


contains a sorted list of selected columns. It enhances the
performance of searching and filtering operations.

8. What is a subquery?

➡A subquery is a query nested within another query. It can be used

r
to retrieve data from one table based on values from another table

e
or perform complex calculations.

d
9. What is a view?

Co
➡ A view is a virtual table derived from one or more tables. It does
not store data but provides a way to present data in a customized or

b
simplified manner.

e
10. What is the di erence between a primary key and a candidate

W
key?

y
➡A candidate key is a column or a set of columns that can uniquely

B
identify each record in a table. A primary key is a chosen candidate

h
key that becomes the main identifier for the table.

c
11. 6. What is the di erence between a schema and a database?

e
T
➡ A database is a collection of related data, while a schema is a
logical container within a database that holds objects like tables,
views, and procedures.

12. What is the di erence between WHERE and HAVING clauses?

➡ WHERE is used to filter rows before grouping in a query, while


HAVING is used to filter grouped rows after grouping.
13. What is the di erence between UNION and JOIN?

➡ UNION combines rows from two or more tables vertically, while


JOIN combines columns from two or more tables horizontally based

@techbywebcoder
on related columns.

14. What is a trigger?

➡A trigger is a set of SQL statements that are automatically executed


in response to a specific event, such as INSERT, UPDATE, or DELETE
operations on a table.

15. What is a stored procedure?

➡A stored procedure is a precompiled set of SQL statements that

r
performs a specific task. It can be called and executed multiple times

e
with di erent parameters.

d
16.What is a transaction?

o
C
➡ A transaction is a logical unit of work that consists of one or more
database operations. It ensures that all operations within the

failing.
eb
transaction are treated as a single unit, either all succeeding or all

yW
17. What is the purpose of the HAVING clause?

➡ The HAVING clause is used to filter grouped rows based on

clause.
hB
specific conditions. It operates on the results of the GROUP BY

ec
18. What is a full outer join?

T
➡ A full outer join returns all rows from both tables, including
unmatched rows, and combines them based on the join condition.
19. What is the purpose of the ORDER BY clause?

➡ The ORDER BY clause is used to sort the result set based on one or
more columns in ascending or descending order.

20. What is a self-referencing foreign key?


➡ A self-referencing foreign key is a foreign key that references the
primary key of the same table. It is used to establish hierarchical

@techbywebcoder
relationships within a single table. 21. What is the purpose of the

GROUP BY clause? ➡ The GROUP BY clause is used to group rows

based on one or more


columns. It is typically used with aggregate functions to perform
calculations on each group. 22.What is the purpose of the DISTINCT

keyword? ➡ The DISTINCT keyword is used to retrieve unique values

r
from a

e
column in a result set, eliminating duplicate rows.

d
23. What is the purpose of the JOIN keyword in the SELECT

o
statement?

C
➡ . The JOIN keyword in the SELECT statement is used to combine

b
rows from two or more tables based on related columns. It allows

e
you to retrieve data from multiple tables in a single query.

W
24. What is the purpose of the LIMIT clause in the SELECT

y
statement?
➡ The LIMIT clause in the SELECT statement is used to restrict the

hB
number of rows returned by a query. It allows you to specify the
maximum number of rows to be retrieved.

ec
25. What is the purpose of the OFFSET clause in the SELECT

T
statement?
➡ The OFFSET clause in the SELECT statement is used in conjunction
with the LIMIT clause to skip a specified number of rows before
starting to return the result set.

26. What is the purpose of the HAVING clause in the SELECT


statement?
➡ The GROUP BY clause in the SELECT statement is used to group
rows based on one or more columns. It is typically used with
aggregate functions to perform calculations on each group.

@techbywebcoder
27. What is the purpose of the AS keyword in the SELECT statement?

➡The AS keyword in the SELECT statement is used to assign an alias


to a column or a table. It allows you to refer to the column or table by
the assigned alias in subsequent parts of the query. 28. What is the

purpose of the ORDER BY clause in the SELECT


statement?
➡The ORDER BY clause in the SELECT statement is used to sort the

order.
er
result set based on one or more columns in ascending or descending

od
such as a progress bar, disk usage, or temperature.

C
29. What is the purpose of the DISTINCT keyword in the SELECT

b
statement?

e
➡- The DISTINCT keyword in the SELECT statement is used to
retrieve unique values from a column in the result set, eliminating
duplicate rows

yW
B
30. What is the purpose of the GROUP BY clause in the SELECT
statement?

ch
➡The GROUP BY clause in the SELECT statement is used to group

e
rows based on one or more columns. It is typically used with

T
aggregate functions to perform calculations on each group.

31. What is the purpose of the UPDATE statement?

➡The UPDATE statement is used to modify existing records in a


table. It allows you to change the values of one or more columns
based on specified conditions.over the positioning and alignment of
elements.
32. What is the purpose of the COMMIT statement?

➡ The COMMIT statement is used to permanently save all changes


made within a transaction to the database. Once committed, the

@techbywebcoder
changes are visible to other users. 33. What is the purpose of the

DELETE statement? ➡The DELETE statement is used to remove one or

more records from


a table. It allows you to delete rows based on specified conditions.
34. What is the purpose of the SAVEPOINT statement?

➡The SAVEPOINT statement is used to define a specific point within

r
a transaction to which you can roll back. It allows you to undo

e
changes up to a specific savepoint without rolling back the entire

d
transaction.

o
35. What is the purpose of the ROLLBACK statement?

bC
➡ The ROLLBACK statement is used to undo all changes made within
a transaction and restore the database to its previous state. It is

e
typically used when an error occurs or when the transaction needs to

W
be canceled.

y
36. What is the purpose of the COALESCE() function?

B
➡ . The COALESCE() function is used to return the first non-null value

h
from a list of expressions. It is often used to provide a default value

c
when a column value is null

Te
37. What is the purpose of the tag in HTML?

➡ The tag is used to draw graphics, animations, and other


visualizations on a web page using JavaScript.
38. What is the purpose of the LEAD() function?

➡ The LEAD() function is used to access the value of a subsequent


row within a result set based on a specified column. It allows you to
compare values across adjacent rows.

39. What is the purpose of the LAG() function?

@techbywebcoder
➡ The LAG() function is used to access the value of a previous row
within a result set based on a specified column. It allows you to
compare values across adjacent rows.
40. What is the purpose of the DENSE_RANK() function?

➡ The DENSE_RANK() function is similar to the RANK() function but


assigns consecutive ranks to rows without gaps. If two rows have the
same rank, the next rank is skipped.

er
41. What is the purpose of the INNER JOIN?

d
➡ The INNER JOIN is a join operation that returns only the matching

o
rows from both tables based on the specified join condition. It

C
combines rows that have matching values in the joined columns.

b
42. What is the purpose of the LEFT JOIN?

e
➡ The LEFT JOIN is a join operation that returns all rows from the left

W
table and the matching rows from the right table based on the

y
specified join condition. If no match is found, null values are

B
returned for the right table columns.

h
43. What is the purpose of the RIGHT JOIN?

ec
➡ The RIGHT JOIN is a join operation that returns all rows from the
right table and the matching rows from the left table based on the

T
specified join condition. If no match is found, null values are
returned for the left table columns.
44. What is the purpose of the FULL OUTER JOIN?

➡ The FULL OUTER JOIN is a join operation that returns all rows from
both tables, including unmatched rows, and combines them based
on the join condition. If no match is found, null values are returned
for the respective columns
45. What is the purpose of the COUNT() function?

@techbywebcoder
➡ The COUNT() function is used to count the number of rows or non-
null values in a column.
46. What is the purpose of the SUM() function?

➡The SUM() function is used to calculate the sum of values in a


column.
47. What is the purpose of the AVG() function?

r
➡ . The AVG() function is used to calculate the average value of a

e
column

d
48. What is the purpose of the MAX() function?

column.
Co
➡ The MAX() function is used to retrieve the maximum value from a

eb
49. . What is the purpose of the MIN() function?

➡ The MIN() function is used to retrieve the minimum value from a


column

yW
50. What is the purpose of the GROUP_CONCAT() function?

hB
➡ The GROUP_CONCAT() function is used to concatenate values from

c
multiple rows into a single string, grouped by a specific column.

Te

@techbywebcoder

You might also like