Sie sind auf Seite 1von 3

SQL Interview Questions

Topic: SQL
61. What is the use of SQL?
Ans: SQL is used to communicate/interact with DBMS/RDBMS.
61. What is the use of SELECT in SQL?
Ans: SELECT is used to select data from a database.
62. What is the use of INSERT in SQL?
Ans: INSERT is used to insert new records in a table.
63. What is the use of UPDATE in SQL?
Ans: UPDATE is used to update existing records in a table.
61. What is the use of DELETE in SQL?
Ans: DELETE is used to delete records in a table.
61. What is the use of WHERE clause in SQL?
Ans: WHERE clause is used to restrict records.
61. What is the use of ORDER BY clause in SQL?
Ans: ORDER BY clause is used to sort the result-set.
62. What is the use of DISTINCT clause in SQL?
Ans: DISTINCT clause is used to return only distinct values.
63. What is the use of IN operator in SQL?
Ans: IN operator is used to specify list of values in a WHERE clause.
64. What is the use of BETWEEN operator in SQL?
Ans: BETWEEN operator is used to specify a range of value in a WHERE clause.
65. What is the use of LIKE operator in SQL?
Ans: LIKE operator is used to search for a specified pattern in a column.
87. Explain wild-card characters in SQL.
Ans: The symbol% ( for a string of any character ) and _ (for any single character ) are the two
wild card characters used in SQL.

81. Differentiate between CHAR and VARCHAR.
SQL Interview Questions

Ans: CHAR holds a fixed length string whereas VARCHAR holds a variable length string.

84. What is Sub-query?
Ans: A subquery is a query within a query. These subqueries can reside in the WHERE clause, the
FROM clause, or the SELECT clause.
85. What is Co-related Sub-query?
Ans: When you reference a column from the table in the parent query in the sub- query, it is
called as co-related sub-query. For each row processed in the parent query, the co-related subquery is
evaluated once.

66. What is the use of SQL Alias?
Ans: When the table name or column name is very long or complex, in that case it can be replaced by a
short and meaningful name and called as alias. It is also useful in case of arithmetic expression.
61. What is the use of JOIN in SQL?
Ans: JOIN is used to query data from two or more tables, based on a relationship between
certain columns in these tables.
62. Differentiate between INNER JOIN and OUTER JOIN.
Ans: An inner join of A and B gives the result of A intersect B whereas outer join of A and B gives
the results of A union B.
63. Differentiate between LEFT OUTER JOIN and RIGHT OUTER JOIN.
Ans: Left Outer Join of A and B will produce all rows in A plus any common rows in B. Whereas
Right Outer Join of A and B will produce all rows in B plus any common rows in A.
64. What is FULL OUTER JOIN?
Ans: A full outer join will give you the union of A and B, i.e. All the rows in A and all the rows in B.
If something in A doesn't have a corresponding datum in B, then the B portion is null, and vice versa.
86. What is Self-join?
Ans: A join created by joining two or more instances of same table is called as Self Join.

80. What is NULL Value?
SQL Interview Questions

Ans: NULL value represent missing/unknown value. By default, a table column can hold NULL values. It
is not possible to test for NULL values with comparison operators, such as =, <, or <>. We will have to use
the IS NULL and IS NOT NULL operators instead.
78. What is the use of NOT NULL Constraint?
Ans: The NOT NULL constraint enforces a column to NOT accept NULL values. The NOT NULL
constraint enforces a field to always contain a value. This means that you cannot insert a new record, or
update a record without adding a value to this field.
79. What is the use of DEFAULT Constraint?
Ans: The DEFAULT constraint is used to insert a default value into a column. The default value will
be added to all new records, if no other value is specified.
82. Differentiate between Scalar (Single-Row) Function and Aggregate (Multi-Row) functions.
Ans: Aggregate functions acts on one or more input and produces only output whereas in case of
single-Row function, the ratio between I/O and O/P is always 1:1.
83. What is the use of GROUP BY in SQL?
Ans: GROUP BY is used in conjunction with the aggregate functions to group the result-set by one or
more columns.
61. What is the use of HAVING clause in SQL?
Ans: HAVING clause is used to restrict groups.

88. Differentiate between TRUNCATE and DELETE.
Ans:
TRUNCATE is a DDL command whereas DELETE is a DML command.
WHERE clause can not be used in TRUNCATE whereas WHERE clause can be used in DELETE.
TRUNCATE is faster in performance wise whereas DELETE is slower than TRUNCATE.
In case of TRUNCATE all object's statistics are dropped and allocated space is released where as
in case of DELETE all object's statistics are kept and allocated space is not released.

Das könnte Ihnen auch gefallen