The largest Interview Solution Library on the web


Interview Questions
« Previous | 0 | 1 | 2 | 3 | 4 | Next »

21.What’s wrong in the following query?

SELECT subject_code, count(nam e)
FROM students;
It doesn’t have a GROUP BY clause. The subject_code should be in the GROUP BY clause.
SELECT subject_code, count(nam e)
FROM students
GROUP BY subject_code;

22.What’s wrong in the following query?

SELECT subject_code, AVG (m arks)
FROM students
WHERE AVG(m arks) > 75
GROUP BY subject_code;
The WHERE clause cannot be used to restrict groups. The HAVING clause should be used.
SELECT subject_code, AVG (m arks)
FROM students
HAVING AVG(m arks) > 75
GROUP BY subject_code;

23.What do you understand by a subquery? When is it used?

A subquery is a SELECT statement embedded in a clause of another SELECT statement. It is used when the inner query, o4r the subquery returns a value that is used by the outer query. It is very useful in selecting some rows in a table with a condition that depends on some data which is contained in the same table.

24.What’s wrong in the following query?

SELECT student_code, nam e
FROM students
WHERE m arks =
(SELECT MAX(m arks)
FROM students
GROUP BY subject_code);
Here a single row operator = is used with a multiple row subquery.

25.What are the various multiple row comparison operators in SQL?

IN, ANY, ALL.

26.What is the pupose of DML statements in SQL?

The DML statements are used to add new rows to a table, update or modify data in existing rows, or remove existing rows from a table.

27.Which statement is used to add a new row in a database table?

The INSERT INTO statement.
Say True or False. Give explanation if False.
While inserting new rows in a table you must list values in the default order of the columns.
True.

28.How do you insert null values in a column while inserting data?

Null values can be inserted into a table by one of the following ways −
Implicitly by omitting the column from the column list.
Explicitly by specifying the NULL keyword in the VALUES clause.

29.How do you copy rows from one table to another?

The INSERT statement can be used to add rows to a table by copying from another table. In this case, a subquery is used in the place of the VALUES clause.

30.What happens if you omit the WHERE clause in the UPDATE statement?

All the rows in the table are modified.

31.Can you modify the rows in a table based on values from another table? Explain.

Yes. Use of subqueries in UPDATE statements allow you to update rows in a table based on values from another table. Say True or False. Give explanation if False. The DELETE statement is used to delete a table from the database. False. The DELETE statement is used for removing existing rows from a table.

32.What happens if you omit the WHERE clause in a delete statement?

All the rows in the table are deleted.

33.Can you remove rows from a table based on values from another table? Explain.

Yes, subqueries can be used to remove rows from a table based on values from another table.
Say True or False. Give explanation if False.
Attempting to delete a record with a value attached to an integrity constraint, returns an error.
True.
Say True or False. Give explanation if False.
You can use a subquery in an INSERT statement.
True.

34.What is the purpose of the MERGE statement in SQL?

The MERGE statement allows conditional update or insertion of data into a database table. It performs an UPDATE if the rows exists, or an INSERT if the row does not exist.
Say True or False. Give explanation if False.
A DDL statement or a DCL statement is automatically committed.
True.

35.What is the difference between VARCHAR2 AND CHAR datatypes?

VARCHAR2 represents variable length character data, whereas CHAR represents fixed length character data.
Say True or False. Give explanation if False.
A DROP TABLE statement can be rolled back.
False. A DROP TABLE statement cannot be rolled back.

36.What is a view? Why should you use a view?

A view is a logical snapshot based on a table or another view. It is used for −
Restricting access to data;
Making complex queries simple;
Ensuring data independency;
Providing different views of same data.
Say True or False. Give explanation if False.
A view doesn’t have data of its own.
True.

37.?

38.?

39.?

40.?

« Previous | 0 | 1 | 2 | 3 | 4 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com