Latest Qualification Jobs

Check Your Email To Activate the Confirmation Link

Top 50 SQL Interview Questions and Answers For 2019 (Beginners/Experience)

Top 50 SQL Interview Questions and Answers

Check Top 50 SQL Interview Questions and Answers from here!! Candidates, preparing for Structured Query Language Interview are suggested to check this page as we have provided SQL Interview Questions and Answers for Beginners/ Experienced candidates on this page. Apart from it, you may download the SQL Queries Interview Questions and Answers PDF also by pressing the given link.

SQL Interview Questions and Answers

Q1: What is Datawarehouse?

Answer: Datawarehouse is a central repository of data from multiple sources of information. Those data are consolidated, transformed and made available for the mining and online processing. Warehouse data have a subset of data called Data Marts.

Q2: What is Self-Join?

Answer: Self-join is set to be query used to compare to itself. This is used to compare values in a column with other values in the same column. ALIAS ES can be used for the same table comparison.

Q3: What is Cross-Join?

Answer: Cross join defines as Cartesian product where number of rows in the first table multiplied by number of rows in the second table. If suppose, WHERE clause is used in cross join then the query will work like an INNER JOIN.

Q4: What Is User Defined Functions?

Answer: User defined functions are the functions written to use that logic whenever required. It is not necessary to write the same logic several times. Instead, function can be called or executed whenever needed.

Q5: What Are All Types Of User Defined Functions?


  • Three types of user defined functions are.
  • Scalar Functions.
  • Inline Table valued functions.
  • Multi statement valued functions.

Scalar returns unit, variant defined the return clause. Other two types return table as a return.

Want to Know? DBMS Interview Questions and Answers

Q6: What Is Collation?

Answer: Collation is defined as set of rules to determine how character data can be sorted and compared. This can be used to compare A and, other language characters and also depends on the width of the characters. ASCII value can be used to compare these character data.

Q7: What Are All Different Types Of Collation Sensitivity?

Answer: Following are different types of collation sensitivity -.

  • Case Sensitivity – A and a and B and b.
  • Accent Sensitivity.
  • Kana Sensitivity – Japanese Kana characters.
  • Width Sensitivity – Single byte character and double byte character.

Q8: What Are The Advantages And Disadvantages Of Stored Procedure?


  • Stored procedure can be used as a modular programming – means create once, store and call for several times whenever required.
  • This supports faster execution instead of executing multiple queries.
  • This reduces network traffic and provides better security to the data.
  • Disadvantage is that it can be executed only in the Database and utilizes more memory in the database server.

Q9: What Is Online Transaction Processing (OLTP)?

Answer: Online Transaction Processing (OLTP) manages transaction based applications which can be used for data entry, data retrieval and data processing. OLTP makes data management simple and efficient. Unlike OLAP systems goal of OLTP systems is serving real-time transactions.

Example – Bank Transactions On A Daily Basis.

Q10: What Is CLAUSE?

Answer: SQL clause is defined to limit the result set by providing condition to the query. This usually filters some rows from the whole set of records.

Example –

  1. Query that has WHERE condition
  2. Query that has HAVING condition.

Q11: What Is Recursive Stored Procedure?

Answer: A stored procedure which calls by itself until it reaches some boundary condition. This recursive function or procedure helps programmers to use the same set of code any number of times.

Q12: What Is Union, Minus And Interact Commands?


  • UNION operator is used to combine the results of two tables, and it eliminates duplicate rows from the tables.
  • MINUS operator is used to return rows from the first query but not from the second query. Matching records of first and second query and other rows from the first query will be displayed as a result set.
  • INTERSECT operator is used to return rows returned by both the queries.

Must Read Latest: Interview Questions and Answers

Q13: What Is An ALIAS Command?

Answer: ALIAS name can be given to a table or column. This alias name can be referred in WHERE clause to identify the table or column.


Select st.StudentID, Ex.Result from student st, Exam as Ex where st.studentID = Ex. StudentID Here, st refers to alias name for student table and Ex refers to alias name for exam table.

Q14: What Is The Difference Between TRUNCATE And DROP Statements?

Answer: TRUNCATE removes all the rows from the table, and it cannot be rolled back. DROP command removes a table from the database and operation cannot be rolled back.

Q15: What Are Aggregate And Scalar Functions?

Answer: Aggregate functions are used to evaluate mathematical calculation and return single values. This can be calculated from the columns in a table. Scalar functions return a single value based on the input value.

Example -.

Aggregate – max(), count – Calculated with respect to numeric.

Scalar – UCASE(), NOW() – Calculated with respect to strings.

Q16: How Can You Create An Empty Table From An Existing Table?

Answer: Example will be -.

Select * into studentcopy from student where 1=2

Here, we are copying student table to another table with the same structure with no rows copied.

Q17: How To Fetch Common Records From Two Tables?

Answer: Common records result set can be achieved by -.

Select student ID from student. <strong>INTERSECT </strong> Select StudentID from Exam

Q18: How To Fetch Alternate Records From A Table?

Answer: Records can be fetched for both Odd and Even row numbers -.

To Display Even Numbers-.

Select studentId from (Select rowno, studentId from student) where mod(rowno,2)=0

To Display Odd Numbers-.

Select studentId from (Select rowno, studentId from student) where mod(rowno,2)=1

from (Select rowno, studentId from student) where mod(rowno,2)=1.[/sql]

Do You Know: How To Overcome Job Interview Fear

Q19: How To Select Unique Records From A Table?


  • Select unique records from a table by using DISTINCT keyword.
  • Select DISTINCT StudentID, StudentName from Student.

Q20: What Is The Command Used To Fetch First 5 Characters Of The String?

Answer: There are many ways to fetch first 5 characters of the string -.

Select SUBSTRING(StudentName,1,5) as studentname from student

Select RIGHT(Studentname,5) as studentname from student

Q21: What is DBMS?

Answer: DBMS is recognized as Database Management System, which is a program that controls creation, maintenance and use of a database. It can be designated as File Manager that manages data in a database rather than saving it in file systems.

Q22: What is RDBMS?

Answer: RDBMS stands for Relational Data Base Management Systems that maintain data records and indices in tables and it may be created and maintained across the data and tables. An RDBMS has the ability to re-join the data items from different files, providing dominant tools for data usage.

Q23: What is SQL?

Answer: SQL is acronym toStructured Query Language which is designed especially for communicating with databases and it is an ANSI (American National Standards Institute) standard.

Q24: What are the different types of SQL’s statements?

Answer: SQL statements are broadly classified into three categories as shown below. This is one of the most frequently asked SQL Interview Questions And Answers.

Q25: what is a field in a database?

Answer: A field is an area within a record reserved for a specific piece of data such as Employee Name, Employee ID, etc.

Q26: What is a Record in a database?

Answer: A record is the collection of values / fields of a specific entity such as an Employee, Salary etc.

Q27: What is a Table in a database?

Answer: A table is a collection of records of a specific type, for example, employee table, salary table etc.

Q28: What is a database transaction?

Answer: The term Database transaction takes database from one reliable state to another. At the end of the transaction, the system must be in the former state, if the transaction fails or the status of the system should replicate the successful completion, if the transaction goes through.

Must Know: Common Interview Mistakes

Q29: What are properties of a transaction?

Answer: Properties of the transaction can be summarized as ACID Properties such as Atomicity, Consistency, Isolation and Durability.

SQL Queries Interview Questions And Answers

The below listed top 10 SQL Query Interview Questions and Answers are based on the following tables, take a look. From below provided link, you can also download SQL Queries Interview Questions And Answers PDF…

Table Name: Employee

12.00.00 AM
12.00.00 AM
12.00.00 AM
12.00.00 AM
12.00.00 AM
12.00.00 AM
12.00.00 AM
12.00.00 AM

Table Name: Incentives


Q30: How we get all employee details from the employee table?

Answer: Select * from employee

Q31: How we get Get First_Name,Last_Name from employee table?

Answer: Select first_name, Last_Name from employee

Q32: How to get First_Name from employee table in upper case?

Answer: Select upper(FIRST_NAME) from EMPLOYEE

Q33: How to get First_Name from employee table in lower case?

Answer: Select lower(FIRST_NAME) from EMPLOYEE

Read Also: Interview Preparation Tips

Q34: How to get unique DEPARTMENT from employee table?

Answer: select distinct DEPARTMENT from EMPLOYEE

Q35: How to get employee details from employee table whose Salary greater than 600000?

Answer: Select * from EMPLOYEE where Salary >600000

Q36: How to get employee details from employee table whose Salary less than 800000?

Answer: Select * from EMPLOYEE where Salary <800000

Q37: How to get difference between JOINING_DATE and INCENTIVE_DATE from employee and incentives table?

Answer: Select FIRST_NAME,INCENTIVE_DATE – JOINING_DATE from employee a inner join incentives B on A.EMPLOYEE_ID=B.EMPLOYEE_REF_ID

Q38: How to get database date?

Answer: You can get database date by using the following command:

  • SQL Queries in Oracle, select sysdate from dual
  • SQL Queries in SQL Server, select getdate()
  • SQL Query in MySQL, select now()

Q39: How to get department,total salary with respect to a department from employee table?

Answer: Select DEPARTMENT,sum(SALARY) Total_Salary from employee group by department

Q40: How to get department wise average salary from employee table order by salary ascending?

Answer: select DEPARTMENT,avg(SALARY) AvgSalary from employee group by DEPARTMENT order by AvgSalaryasc

Read Out Here: BPO Interview Questions and Answers

SQL Server Interview Questions And Answers

Q41: How can SQL Server instances be hidden?

Answer: In order to hide a SQL Server instance, we need to make a change in SQL Server Configuration Manager. To do so, launch SQL Server Configuration Manager and do the following: select the instance of SQL Server, right click and select Properties.

After selecting properties, you will just set Hide Instance to “Yes” and click OK or Apply, after the change is made, you have to restart the instance of SQL Server to not expose the name of the instance.

Q42: Can we take backup for Resource DB?

Answer: No, the only way if you want to get a backup by using windows backup for option resource MDF and LDF files.

Check Out: SQL Server Interview Questions And Answers

SQL Joins Interview Questions And Answers

Q43: What is the use of a join in SQL?

Answer: Joins in Structured Query Language can be used for retrieving data from two or more tables into the result set.

Q44: What are the different types of SQL JOIN clauses?

Answer: There are multiple types of JOIN clauses such as INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN and CROSS JOIN.

PL SQL Interview Questions And Answers

Q45: What is PL/SQL?

Answer: PL/SQL is a technical language that has both interactive Structured Query Language and procedural programming language concepts such as iteration, conditional branching.

Q46: What are the uses of database trigger?

Answer: It is used for the following:

  • Audit data modifications.
  • Log events transparently.
  • Enforce complex business rules.
  • Maintain replica tables
  • Derive column values
  • Implement Complex security authorizations

You May Read This: Interview Preparation Tips For Getting A Job

Oracle SQL Interview Questions And Answers

Q47: In which language Oracle has been developed?

Answer: Oracle has been developed using C Language.

Q48: What is RAW datatype?

Answer: RAW datatype is used to hold values in binary data format and maximum size for a raw in a table in 32767 bytes.

SQL Server DBA Interview Questions And Answers

Q49: Why would we use SQL Agent?

Answer: SQL Agent is the job scheduling tool in SQL Server and jobs can be scheduled to run at a set time or when a specific event occurs. It is most often used to schedule managerial jobs such as backups.

Q50: What is DBCC?

Answer: The term DBCC is recognized as Database Console Commands and come in four flavors such as Maintenance, Informational, Validation, and Miscellaneous.

Download Here: SQL Interview Questions and Answers PDF

Structured Query Language (SQL)

SQL (Structured Query Language) is a language which is used to interrelate with the database such as to create a database, to create a table in the database, to retrieve data or update a table in the database etc.

Structured Query Language is based on ANSI (American National Standards Institute) standard. This language can help you to do many things like executing queries, inserting records in a table, updating records, creating a database, creating a table, deleting a table etc.

Do You Know: How to Answer Confusing Interview Questions

Role of

We hope above provided SQL Interview Questions and Answers are helpful for you to prepare for SQL Interview session. You can visit our page again to get latest updates regarding the SQL Queries Interview Questions and Answers for 3 Years’ Experience, SQL DBA Interview Questions And Answers etc.

Students, who have any questions regarding Oracle PL/SQL Interview Questions And Answers and SQL Interview Questions And Answers For Experienced / Fresher, they can leave a comment in the box displayed to you below. Our expert’s team of will try to sort out your problem quickly.

Something That You Should Put An Eye On

How To Dress For An InterviewPersonality Improvement Tips
Latest Jobs Openings For FreshersEmployment News This Week Highlights
Group Discussion: Dos and Don’tsLatest Private Jobs
Jobs By QualificationJobs by Organization

Filed in: Question & Answers Tags: 

Leave a Reply

Submit Comment