SQL Questions

Q:

What is the difference between JOIN and UNION?

Answer

SQL JOIN allows access to records of other table based on the given conditions between two tables.


Ex: If we are provided with the department ID of each employee, then we can use the department ID of the employee table to merge with the department ID of the department table to access department names.


UNION operation allows addition of 2 similar data sets to create a resulting set that contains all the data from the source data sets.


Ex: If we are provided with 2 employee tables of the same structure, we can UNION them to create a singular result that will contain all employee from both the table.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL - Technology

1 3845
Q:

What operator tests column for the absence of data?

A) NOT operator B) IS NULL operator
C) EXISTS operator D) All of the above
 
Answer & Explanation Answer: B) IS NULL operator

Explanation:

SELECT "column_name"


FROM "table_name"


WHERE "column_name" IS NULL.

Report Error

View Answer Report Error Discuss

1 3731
Q:

How can you generate debugging output from PL/SQL?

Answer

Use the DBMS_OUTPUT package. Another possible method is to use the SHOW ERROR command.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL - Technology

0 3698
Q:

What is Log Shipping?

Answer

Log shipping is the process of automating the backup of database and transaction log files on a production SQL server, and then restoring them onto a standby server. Enterprise Editions only supports log shipping. In log shipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db and can be used this as the Disaster Recovery plan. The key feature of log shipping is that it will automatically backup transaction logs throughout the day and automatically restore them on the standby server at defined interval.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL - Technology

0 3599
Q:

SQL views can be used to hide?

A) Complicated SQL syntax B) Rows
C) Columns D) All of the above
 
Answer & Explanation Answer: D) All of the above

Explanation:

In SQL, a SQL view is a virtual table based on the result-set of an SQL statement. A view contains rows and columns, just like a real table.

 

SQL views can be used to hide rows and columns and complicated SQL syntax.

 

The fields in a view are fields from one or more real tables in the database.

Report Error

View Answer Report Error Discuss

Filed Under: SQL - Technology
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

3 3517
Q:

Write SQL Query to find second highest salary of Employee.

Answer

There are many ways to find second highest salary of Employee in SQL, you can either use SQL Join or Subquery to solve this problem. Here is SQL query using Subquery :


SELECT MAX(Salary) from Employee WHERE Salary NOT IN (select MAX(Salary) FROM Employee );

Report Error

View answer Workspace Report Error Discuss

Subject: SQL - Technology

2 3388
Q:

How to rebuild Master Database?

Answer

Master database is system database and it contains information about running server's configuration. When SQL Server 2005 is installed it usually creates master, model, msdb, tempdb resource and distribution system database by default. Only Master database is th one which is absolutely must have database. Without Master database SQL Server cannot be started. This is the reason it is extremely important to backup Master database.


To rebuild the Master database, Run Setup.exe, verify, and repair a SQL Server instance, and rebuild the system databases. This procedure is most often used to rebuild the master database for a corrupted installation of SQL Server.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL - Technology

0 3359
Q:

State one similarity and difference between WHERE Clause and HAVING Clause?

Answer

Similarity: Both WHERE and HAVING Clause filters out records based on one or more conditions.


Difference: WHERE Clause can only be applied to a static non-aggregated column whereas HAVING is needed for aggregated columns.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL - Technology

1 3188