Monday, January 30, 2017

Basic SQL Interview Questions and answers

In this article I am sharing SQL Interview Questions For freshers and experienced developers. i have been sharing all types technology interview Questions keep follow me for updated Interview Questions. In this page we will learn SQL Interview Questions as follows

1) What is SQL?
Ans: SQL means Structured Query Language(SQL) is a language designed specially for communicating with databases.After stored data in the database we can easily update records,deleting records,creating and modifying tables. Using SQL it is easier to manage database systems without having to write substantial amount of code.

2)  Why SQL is important?

Ans:  SQL is a Query processing language and is the most important data processing language in use today. It is not a complete programming language like JAVA or C# but a data sub language used for creating and processing database data and metadata. All DBMS products today use SQL.

3)  What are the Advantages of SQL?

Ans: SQL is easy to learn.SQL is actually a very powerful query language and by using its language elements you can perform very complex database operations. This is the Query language will enable programmers to interact with any database like ORACLE,SQL,MYSQL etc..

4) What is difference between IN and BETWEEN that are used inside a WHERE clause?

Ans: The BETWEEN clause is used to fetch a range of values,whereas the IN clause fetches data from a list of specified values.

5) What are Wildcard 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.

6) What is primary key?

Ans: A primary key is a column whose values uniquely identify every row in a table. Primary key values can never be reused. If a row is deleted from the table,its primary key may not be assigned to any new rows in the future. No two rows can have the same primary key value.

7) What is Composite Key?

Ans:  A composite primary key is a type of candidate key,which represents a set of columns whose values uniquely identify every row in a table. For example: if "employe_id" and "employee_name" in a table is combined to uniquely identify a row its called a composite key.

8) What is Foreign Key?

Ans: When a one table's primary key filed is added to a related many table in order to create the common filed which relates the two tables,it is called a foreign key in the many table.

9) What is Unique Key?

Ans: Unique key is same as primary with the difference being the existence of null. Unique key filed allows one value as NULL value.

10) What is Candidate Key?

Ans: A table may have more than one combination of columns that could uniquely identify the rows in a table,each combination is a candidate key.

11) What is sqLite?

Ans: SQLite is an relational database management system contained in a relatively small C library. SQLite is a public domain project developed.

12) What is the function of truncate?

Ans: With the Truncate statement,you can delete all the content in the table,but keep the actual table intact and ready for further use.

13) What is the function of ALTER?

Ans: The ALTER Statement permits the user to modify an existing object in various ways. For example, by adding a column to an existing table.

14) What is SQL insert statement?

Ans: SQL INSERT statement is used to add rows to a table.

15) What is Join?

Ans: In order to avoid data duplication,data is stored in related tables. Join keyword is used to fetch data from related tables. Join return rows when there is at least one match in both table.

16) What is Stored Procedure?

Ans: Stored Procedure is a function which contains a collection of SQL Queries. The procedure can take inputs,process them and send back output.

17) What are the advantages of Stored Procedure?

Ans:  Stored Procedures are pre compiled and stored in the database. This enables the database to execute the queries much faster. Since many queries can be included in a stored procedure,round trip time to execute multiple queries from source code to database and back is avoided.

18) What is view?

Ans: The views are virtual tables. Unlike tables that contain data,views simply contain queries that dynamically retrieve data when used.

19) What is difference between cluster and non cluster index?

Ans:  A cluster index reorders the way records in the table are physically stored. There can be only one clustered index per table. It makes data retrieval faster.

A non cluster index does not alter the way it was stored but creates a completely separate object within the table. As a result insert and update command will be faster.

20) What is difference between SQL and PL/SQL?

Ans: SQL is a structured Query Language whereas PL/SQL is a procedural Query Language. PL/SQL is a collection of queries.

21) What are the ACID Rules?

Ans: Some of the ACID rules stated are described as follows:

Atomicity: Either transaction should be done or they should be stopped
Consistency: Data should never be in a contradictory state
Isolation: Two simulaneous or preceding results should never interfere with each other.
Durability: Results or Data shouldn't be discarded even during a crash of the system.

22) What is Transaction?

Ans: Database Transaction takes database from one consistent state to another. At the end of the transaction the system must be in the prior state if the transaction fails or the status of the system should reflect the successful completion if the transaction goes through

23)  What the advantages of views?

Ans: The view can be used to hide some of the columns from a table. Views can provide access restriction,since data insertion,update and deletion is not possible with the view.Views don't store data in physical location

24) What is Union,minus and intersect commands?

Ans: Minus operator is used to return rows from the first query but not from the second query. INTERSECT operator is used to return by both the queries. 


25) What is use of GROUP BY and HAVING clause?

Ans: The GROUP BY partitions the selected rows on the distinct values of the column on which the group by has been done. The Having selects groups which match the criteria specified.


Let me know your comments on this post and keep follow me for updated interview questions and share this post to your friends.

1 comment:

High Paying Jobs after Learning Python

Everyone knows Python is one of the most demand Programming Language. It is a computer programming language to build web applications and sc...