Sql Q&A
Sql Q&A
Language
Question
1. What is SQL?
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?
@techbywebcoder
7.What is a non-clustered index
8. What is a subquery?
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.
@techbywebcoder
on related columns.
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?
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.
@techbywebcoder
relationships within a single table. 21. What is the purpose of the
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.
@techbywebcoder
27. What is the purpose of the AS keyword in the SELECT statement?
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.
@techbywebcoder
changes are visible to other users. 33. What is the purpose of the
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?
@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?
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?
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?
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