Last Updated: July 3rd, 2018
If you're looking for SQL Interview Questions for Experienced or Freshers, you are at right place. There are lot of opportunities from many reputed companies in the world. SQL database market continue even stronger by 2020 will be 70%. According to a research SQL by Microsoft grew at 10.32%, while Oracle grew 3.5%. In the upcoming era, competition will be more heated than is has been for years. So, You still have opportunity to move ahead in your career in SQL certification guide. Mindmajix offers Advanced SQL Interview Questions 2018 that helps you in cracking your interview & acquire dream career as SQL Developer.
|SQL Vs NoSQL|
|Type of Data Base||Relational data base||Non relational data base/Distributed data base|
|Standardardization||Standard Query Language exist||No proper standards defined|
|Reporting Tools||Various tools available to analyse performance||Unaivalability of tools to analyse data and performance|
|Development model||Fine grained database model||Architects can create new DB models|
|Price||Expensive compared to NoSQL||Low Cost - Mostly Open Source|
|Schema||Predefined Schema available||Unstructured data with dynamic schema|
|Database Examples||PostGres, Sqlite, Oracle, etc.,||BigTable, Cassandra, MongoDB, etc.,|
|Type of Data storage||Not suitable for hierarchial data storage||Best suitable for hierarchial data.|
Q2) What do you know about a Database Management system?
It is basically a program which is considered when it comes to maintaining, creating, deploying, controlling as well as monitoring the use of a database. It can also be considered as a file manager which is good enough to be trusted for managing the data kept in a database than a file system. Database approach is really a good one as it being numerous benefits for the organizations. The entire data can easily be managed simply irrespective of its size and complexity.
Q3) What do you mean by Fields and Tables and how they are useful?
Basically, a table is a set of different rows and columns and is organized in a model. The manner of columns and rows are vertical and horizontal. In a table, there are some specific numbers of columns which remains present and is generally known as fields. There is no strict upper limit on the overall number of records which are defined by rows in the table.
Q4) Compare SQL with Oracle?
|It is more scalable and secure than Oracle||Oracle too is secure and scalable but not upto the extent SQL|
|It widely support procedural extensions||The support to the same is limited|
Q5) How the Inner Join in SQL is different from that of Outer Join?
An Inner join is the one that is useful for the purpose of returning the rows provided at least two tables are met critically. On the other hand, the outer Join is the one that is useful for returning the value of rows and tables that generally include the records that must be same in all the tables.
Q6) Can you tell something about the Primary key in SQL and what is its significance?
It is basically an array or a group of fields that generally specify a row. It is considered as one of the unique keys that always have some defined or specific value. Generally, the users need not to worry about anything when it is enabled as it cannot have a null value. It is capable to identify all the records in a database simply and the users are free to get the best possible outcome with minimum efforts. This is exactly what that makes sure of uniqueness.
Q7) What do you know about the database testing and how it can help getting useful results for the database users?
It is basically nothing but the back end testing or the data testing. It generally involves keeping an eye on the integrity of the data an organization use. It generally validates some of the very useful tasks such as database, indexes, columns, tables as well as triggers. IT also make sure that no duplicate data exist in the database which causes a very large number of problems and the best part is the junk records can also be trashed in a very reliable manner. The updating of record is also a task that can be made easy with the help of this approach.
Q8) Tell something you know about the SQL constraints?
These are some important rules in the SQL which are responsible for the restrictions when it comes to deleting, updating or changing the primary data present in the database.
Q9) In SQL, what do you know about the composite primary key?
The key which is created on multiple columns in a table is generally considered as the Composite primary key. However, it is not always necessary that all of them have a same meaning.
Q10) Difference Between Stored Procedure & Functions?
|It is a set of pre-compiled SQL Statements which will gets executed when we call it||It will take input from user and return only one value of any data type|
|Compile only one time||Compile every time|
|Stored Procedure will have execution plan||Function will not have execution plan|
|Support DML Commands||Not supported DML Commands|
|Support TCL Commands||Not supported TCL Commands|
|It is may or may not have input parameter||Function must have at least one input parameter|
|It is accept both input and output parameters||Doesn’t have output parameters|
|We call call stored procedure in another stored procedure||We can call function in another function|
|It is support Exception Handling||It is doesn’t support Exception Handling|
|We can call function in stored Procedure||We can’t call stored procedure in function|
Q11) What do you know about Field in a Database?
It is basically a space that is allotted for storing some records that are present within a table. There are actually different fields and it is not always necessary that all the fields are same in terms of size and allocation pattern.
Q12) Name a few commands which you think are important in SQL for managing the database?
You can answer this questions based on the commands you have used in your past if you having a bit experience in SQL. Else, the following commands are there which are widely adopted and are very useful.
1.Data Definition Language
2.Transaction Control Language
3. Data Query Language
4. Data Manipulation Language
5. Data Control Language
Q13) Name a few important DDL commands present in the SQL?
They are generally preferred when it comes to defining or changing the structure of a specific database in the shortest possible times due to security and other concerns. Some of the commands that can be applied and considered directly for this are as follows.
Create, Alter, Drop, Rename, Truncate and copy
Q14) Tell something about the Temp Table?
It is basically a structure in the SQL that is sued for storing any sort of data that is not permanent or need to be stored for a specific time period. Depending on the needs, it is possible to extend the space upto any extend. Generally, a limited space is kept reserved as the temp table.
Q15) Name any two commands that are used for the purpose of managing the data present in the database
These are Update and Insert
16) What do you mean by Term and how it is different from that of Index?
When it comes to handling the queries at a faster rate, the Indexes are preferred widely in SQL and they simply make sure of quick retrieval of the data and the concerned information from the table present in the database. It is possible to create the index on a single column or a group of same.
On the other side, a View is basically nothing but the subset of a table and is used for the purpose of storing the database in a logical manner. It is actually a virtual table that has rows as well as the columns which are similar to that of a real table. However, the views contain data that actually don’t belong to them. The same is considered when it comes to restricting the access of a database.
Q17) Is it possible for the users to compare the test for the NULL values in SQL?
No, the same is not possible
Q18) What do you mean by the term SQL?
It stands for Structured Query Language and is a powerful language to communicate the database and monitor the concerned tasks easily and reliably. A lot of important tasks such as updating the database, controlling, modifications, as well as deletion of data can be performed with this task. It comes with so many dedicated features in it that are good enough to make a database completely useful and reliable to consider. There are many commands that can be considered and help saving a lot of time when it comes to getting the best out of a database.
Q19) Tell something about Subquery in the SQL?
It is basically a SQL query and is generally regarded as the subset of the select statement and the process of those tasks that generally make sure of filtering the conditions related to the main query.
Q20) In a query, is it possible for the users to avoid the duplicate records? How this can be done?
Yes, the same is possible and there are many methods that can help users to get the favorable fortune in this matter. The best one is to deploy the SQL SELECT DISTINCT query which is sued to return the unique values. All the repeated values or the ones which are duplicate get deleted automatically.
Q21) What is the significance of the default constraint in SQL?
It is used when it comes to including a default value in a column in case there is no new value provided at the time a record is inserted.
Q22) What are the factors that can affect the functionality of a database according to you?
There are certain things that largely matters. The first and the foremost is nothing but the size of the database in terms of its storing capacity. Of course, for a bigger database, the needs are complex and so does its management. Thus, the first thing that can help keeping up the pace in this matter is a powerful query language or a controlling procedure. Next thing is the security of the database. In addition to this, the experience of the experts handling the important operations can also largely impact the database. Moreover, there are conditions on the operation of the same that also largely matter.
Q23) How can you put separate the Rename and the Alias?
A permanent name which is given to a table or a column in SQL is considered as “Rename” whereas the temporary name
given to the same is considered as “Alias”
Q24) What is a Join and what are the different types of same present in the SQL?
Join is basically a query that is useful for the purpose of retrieving the columns and the rows. It is useful when the users have to handle a very large number of tables at the same time. The different types of Joins that are present in the SQL are Right Jin, Inner Join, Left Join, Outer Join and Upper Join.
Q25) What do you know about the NULL value in the SQL?
It is basically a field which doesn’t have any value in SQL. It is totally different from that of a zero value and must not be put equal or confused with the same. These fields are left blank during the creation of the records.
Q26) How can you say Normalization is a useful process in database management?
It is basically an approach with one of its primary aim is to simply impose a strict upper limit on the redundancy of the data. The users are free to go ahead with many of the normalizations forms present in the SQL and a few of them are First, second, third and Boyce Normal Form.
Q27) What do you know about the stored procedure?
It is nothing but an array of some important SQL statements that are stored in the database and are responsible for performing a specific task.
Q28) Name the SQL procedure which makes sure an immediate action in response to an event?
The same is Trigger
Q29) In the Boolean Data Field, what are the possible values that users can simply store?
This can be TRUE or FALSE
Q30) Name the types of Indexes of which are available in SQL
There are three important types of Indexes and they are Unique Index, Clustered Index as well as Non Clustered Index.
Q31) In SQL, what is the best thing about the Views you have come across?
These are several good things about them. The very first thing is they consume almost no space which makes them good enough to be considered at every situation. At the same time, the users are able to consider views for simply retrieving the outcomes that belongs to queries which are complicated in nature. The same may need to be executed frequently. It is possible to consider this when it comes to restricting the access to the database.
SQL- A Structured Query Language, It is also pronounced as “SEQUEL” and it an Non-procedural Language which is used to operate all relational database. Used for Database communication. Its a standard language that can be used to perform the tasks like data retrieval, data update, insert or delete data from an database.
SQL is more natural than MYSQL. MySQL is a computer application. whose DBMS allows multiple users. It enables access to several database application and management system. SQL is more natural and standard language that is used with different applications alike. But, however no organization actually employs this standard language, rather every software firm follows its own kind of SQL version.
|SQL Vs MySQL|
|SQL stands for Structured Query Language||MySQL is a RDMS (Relational Database Management System)|
|Allow for accessing and manipulating db's||MySQL is a database management system, like SQL Server, Oracle, Postgres, Informix etc|
|Basically works as the prompter to a DBMS||It Facilitates multi-user access to a huge number of DBs|
|SQL codes & commands are used in various DBMS and RDBMS systems such as MySQL.||MySQL has SQL at its core, and requires future upgrades mostly|
Q34) What is SQL Server?
SQL Server is Microsoft's relational database management system (RDBMS). End user cannot interact directly with database server. If we want to interact with SQL database server then we have to interact with SQL.
Q35) What are the different types of SQL’s statements?
1. DQL - Data Query Language ( or) Data Retrival Language
2. DML – Data Manipulation Language
DML is used for manipulation of the data itself.
3. DDL – Data Definition Language
DDL is used to define the structure that holds the data.
4. DCL – Data Control Language
DCL is used to control the visibility of data.
5. TCL - Transaction Control Language
Q36) What are various DDL commands in SQL? Give brief description of their purposes.
DDL Commands are used to define structure of the table
It is used to create database objects like tables, views, synonyms, indexes.
Create table table_name(columname1 datatype(size), columname2 datatype(size),....);
It is used to change existing table structure.
Alter:: a) add
It is used to add columns into existing table
Alter table table_name add(columnname1 datatype(size), columname2 datatype(size),....);
It is used to change column Datatype or datatype size only.
Alter table table_name modify(columnname1 datatype(size), columnname2 datatype(size),....);
It is used to drop columns from the table.
If we want to drop single column at a time without using parentheses then we are using following syntax.
alter table table_namedrop column col_name1; -- drop ONE column
If we want to drop single or multiple columns at a time with using paranthesis then we are using following syntax.
alter table table_name drop(column_name_list);
In all databases we can’t drop all columns in the table.
It is used to remove database objects from database.
Drop object object_name;
Drop table table_name;
Drop view view_name;
It is used to renaming a table.
Rename old table_name to new table_name;
Renaming a column:
Alter table table_name rename column old column_name to new column_name;
Oracle 7.0 introduced truncate table command it is used to delete all rows permanently from the table.
truncate table table_name;
Q37) What are various DML commands in SQL? Give brief description of their purposes.
DML Commands are used to manipulate data within a table.
There are:: INSERT, UPDATE, DELETE
1. INSERT − It is used to insert data into in the table
Insert into table_name values(values1, value2, value3,……);
Method2:- Using Substitutional operator (&)
Insert into table_name values(& columnname1, columnname2,.....);
Method3:- Skipping columns
Insert into table_name(col1, col2,...) values(val1, val2, val3,...);
2. UPDATE - It is used to change data in a table.
Update table_name set columnname=new value where columnname=old value;
Note: In all databases we can also use update statement for inserting data into particular shell.
3. DELETE - It is used to delete rows or particular rows from a table.
Delete from table_name;
Delete from tablename where condition;
Q38) Difference Between Delete & Truncate?
|SQL Delete Vs SQL Truncate|
|It is DML Command||It is DDL Command|
|It is used to delete all the records row by row||It is used to delete all the records at a time|
|By using delete command we can delete specific record||By using truncate we cannot delete specific record|
|Where condition we can use with delete command||Where condition will not work with truncate|
|Delete will work slow compare with truncate||Truncate will work fast compare with delete|
|Delete will not reset auto generate id. Once when we delete all the records from the table.||Truncate will reset auto generate id from starting number.|
Q39) About The SQL Buffer?
Q40) What are Important SQL Functions?
Q41) How to Open SQL Server?
Goto -> Start -> All Programms -> Microsoft SQL Server 2008 R2 -> SQL Server management Studio.
Q42) What is SQL Injections? And How to Prevent SQL Injection Attacks?
It is a mechanism of getting secure data from database.
SQL Injection Attacks::
Q43) Difference Between Scalar Valued Functions & Table Valued Functions in SQL?
|SQL Scalar Valued Functions Vs SQL Table Valued Functions|
|Scalar Valued Functions||Table Valued Functions|
|It will process on single row ata time & return only one value of any database||It will process on multiple rows at a time & return multiple rows (or) single row from table|
|The return type of scalar valued function is datatype||The return type of table valued function is table|
|Scalar valued function will have as begin block end||Table valued function will not have as begin end|
Syntax to call Scalar Valued Functions is::
Syntax to call Table Valued Functions is::
Q44) How can you say that Database testing is different from that of GUI testing?
Q45) Write a Query to view the indexes that are applied on the table?
stored procedure_helpindex table_name
Q46) Difference Between Long & Lob Datatypes?
|It stores upto 2GB Data||It stores upto 4 GB Data|
|A table can contain only one long column||A table can contain more than Lob column|
|Subquery cannot select a Long datatype column||Subquery can select Lob Column|
Q47) Difference Between (Null Value Function) nvl() & Coalesce()
SELECT nvl(‘a’, sysdate) FROM dual;
SELECT Coalesce(‘a’, sysdate) FROM dual;
Error: inconsistent datatypes: expected CHAR got DATE
Q48) What is Tuple?
Tuples are the members of a relation. An entity type having attributes can be represented by set of these attributes called tuple.
Q49) What is Query & Query Language?
Q50) Difference Between Views & Materialized Views?
|View does not store data||Materialized view stores data|
|Security purpose||Improved performance purpose|
|When we ar4e dropping base table then view can’t be accessible||When we are dropping base table also materialized view can be accessible|
|Through the view we can perform DML Operation||We can’t perform DML operation|
Q51) What are the different aggregate functions in SQL?
AVG(), MIN(), MAX(), SUM(), COUNT()
Q52) What is data independence?
A database system keeps data separate from software data structure.
Q53) What is data integrity?
Data must satisfy the integrity constraints of the system for data Quality.
Q54) What is Dead locking?
It is the situation where two transactions are waiting for other to release a lock on an item.
Q55) What is decryption?
Taking encoded text and converting it into text that you are able to read.
Q56) What is projection?
The Projection of a relation is defined as projection of all its tuples over a set of attributes. It yields vertical subset of the relation. The projection operation is used to view the number of attributes in the resultant relation or to reorder attributes.
Q57) What is Encryption?
Encryption is the coding or scrambling of data so that humans can not read them directly.
Q58) What is cardinality?
The number of instances of each entity involved in an instance of a relation of a relationship describe how often an entity can participate in relation ship. (1:1, 1:many, many:many).
Q59) What is Transaction Control?
Q60) What are the Transaction Start & End Cases?
Q61) GRANT Command?
GRANT Command is Used When We Want The Database To Be Shared With Other Users.
The Other Users Are GRANTED With Certain Type of RIGHTS.
GRANT Command Can Be issued Not Only on TABLE OBJECT, But Also on VIEWS, SYNONYMS, INDEXES, SEQUENCES Etc.
Q62) REVOKE Command?
REVOKE Command is Used When We Want One Database To Stop Sharing The Information With Other Users.
Revoke Privileges is Assigned Not Only On TABLE Object, But Also on VIEWS, SYNONYMS, INDEXES Etc.
SQL> REVOKE INSERT, DELETE
Q63) Connecting to Oracle OR SQL * Plus?
Double Click the
SQL*Plus ShortCut on the Desktop.
Start -> Run -> Type SQLPlus OR SQLPlusW in Open Box and Click OK.
Start -> Programs -> Oracle -> Application Development -> SQL*Plus
In the Login Box OR Login Prompt Type the User Name and Password as Supplied by the Administrator.
The Host String is Optional and is provided by the Administrator.
Q64) About PL/SQL Tables?
Q65) Difference Between SQL and PL/SQL?
|It’s complete name is structured query language||It’s complete name is procedural Language / Structured Query Language|
|It doesn’t have the any facility of branching or looping||It has the complete facility of branching or looping|
|In SQL, only one statement can be sent to Oracle Engine.||It increase the execution time In PL/SQL, a complete block of statements can be sent to Oracle engine at a time, reducing traffic|
|In SQL, the use of variables is not possible||In PL/SQL, the results of the statements can be stored in variables and can be used further as per the requirement|
|It doesn’t have the capacity for procedural language||It is fully support procedural language|
|In SQL, there is no facility of error management. In case of error condition, It is the Oracle Engine that tracks it.||In PL/SQL, the results of the statements can be stored in variables and can be used further as per the requirement|
Q66) What is a CURSOR?
CURSOR is a Handle, OR Pointer To The CONTEXT AREA
Q67) What is The CURSOR Usage?
Using a CURSOR, The PL/SQL program can control the CONTEXT AREA, As the SQL Statement is being processed.
Q68) What are the CURSOR Features?
Q69) What are the Different Types of Constraints?
Output: enter value for ename:murali
Employee doe snot exists
Output: enter value for ename:KING
Employee exists KING 7400
Q71) Explain Eliminating Explicit Cursor Life Cycle (or) Cursor FOR Loops?
Using cursor for loop we are eliminating explicit cursor life cycle i.e whenever we are using cursor for loop no need to use open, fetch, close statement explicitly i.e when we are using cursor for loop oracle server only internally automatically open the cursor, and then fetch data from the cursor and close the cursor.
varname in cursorname
In cursor for loop index variable internally behaves like a record type variable. (%row type)
Q72) What are the Cursor Attributes?
|Attribute Name||Return Value||Condition|
If fetch statement return at least one row
If fetch statement doesn't returns any row
If fetch statement doesn't returns any row
If fetch statement return at least one row
If cursor is already opened
If cursor is not opened
|If counts number of records number fetches from the cursor|
Q73) What is Autonomous Transaction?
Q74) What is Out Mode?
We can also use out mode parameter i function, but these functions are not allowed to execute by using select statement. If we want to return more no.of values from a function then only we are allowed to use out parameter. Here also out parameter behaves like a uninitialized variables.
Q75) What is SQL Loader?
SQL Loader is an utility program which is used to transfer data from flat into oracle database. SQL Loader always executes control file based on the type of flat file we are creating control file and then submit conrol file to SQL loader then only SQL loader transfer file into flat file into oracle Data Base during this file some other files also created.
sql%bulk_rowcount attribute which is used to count affected number of rows within each group in bulk bind process. (forall statements).
Q77) Authid current_user
Q78) What is Row-Level-Attribute?
In this method a single variables can represent all different datatype into single unit. This variable is also called as record type variable.
Ro Level Attribute are represented by using %rowtype.
Q79) What are types of Blocks in PL/SQL?
PL/SQL having 2 types of blocks
1. Anonymous Block
2. Nammed Block
|Anonymous Block||Nammed Block|
|This block doesnot have a name||This block having a name|
|These blocks are not stored in oracle database||These blocks are automatically permanently stored in Database|
|Thess blocks are not allowed to call in client application||These blocks are allowed to call in client application|
Q80) Write a PL/SQL cursor program which is used to display total salary from emp table without using sum() function by using cursor for loop?
Q81) What is Normalization?
Normalization is a scientific process which is called to decomposing a table into number of tables. This process automatically reduces duplicate data and also automatically avoids insertion, updation, deletion problems.
In design phase of SDLC database designers designs LOGICAL MODEL of the database in this logical model only database designers uses normalization process by using normal forms.
Q82) What is Super Key?
A columns or a combination of columns which uniquely identifying a record in a table is called a Super Key.
Q83) What is Candidate Key?
A minimal super key uniquely identifying a record a table is called candidate key
A super key which is a subset of another super key then those super keys are not a candidate key.
Q84) What is Bad File?
This file extension is .bad
Bad file stores rejected records based on
Bad file is automatically created as same name as Flat file, we can also create Bad file explicitally by using bad file clause within control file.
Q85) What is Discard File?
Q86) What is Autoincrement?
In all databases generating primary key value automatically is called auto increment concept. In Oracle we are implementing auto increment concept by using row level triggers, sequences. i.e here we creating sequence in sql and use this sequence in PL/SQL row level trigger.
SQL> create table test (sno number(10), primary key, name varchar2(10));
Q87) What is Dynamic SQL?
It is the combination of SQL, PL/SQL i.e SQL statements are executed dynamically with PL/SQL block using execute immediate clause.
Generally in PL/SQL block we are not allow to use DDL, DCL statements using Dynamic SQL DDL, DCL statement within PL/SQL block.
Q88) What are the Different SQL Servers Versions avialable in the market?
|SQL Servers Versions|
|SQL Server||Code Name|
|SQL Server 2017||vNext|
|SQL Server 2016||Helsinki|
|SQL Server 2014||Hekaton|
|SQL Server 2012||Denali|
|SQL Server 2008 R2||Kilimanjaro|
|SQL Server 2008||Katmai|
|SQL Server 2005||Yukon|
|SQL Server 2000||Shiloh|
|SQL Server 7.0||Sphinx|
Q89) Write a dynamic SQL program to display number of records from emp table?
Q90. Write a dynamic SQL program for passing department number 20 retrieve deptnames, Loc from dept table?
|SSRS||SQL Server DBA|
|Team Foundation Server||BizTalk Server Administrator|