-
SQL Interview Questions For Tech Mahindra :
I have studied lot of websites and data related to the SQL interview questions for Tech Mahindra and different companies.I come up with questions and it answers which have been recently asked in Tech mahindra Interview.I have added IBM Interview Questions also which are useful questions for IBM Company.I will keep updating the questions weekly or in 15 days so that the users of this site will get very useful information about what kind of SQL questions asked in different companies and users will get proper idea and company wise bifurcation of the questions and answers.Following are some important SQL Interview Questions for Tech Mahindra :
1.What is subquery and what are different types of subqueries?
Answer:
Subquery is query within a query.There are 2 or more types of queries used to fetch output of the query.One is query used inside the query which is known as inner query and the output of query is given to the query which is used outside.The query used outside is called as outer query.Subquery is made up of combining two types of Queries the first type is outer query and other is inner query.
Following are different types of subqueries:
1.Single Row Subquery
2.Multi row Subquery
3.Co-Related Subquery
4.Scalar Subquery
5.Nested SubQuery.
Click Here to get More Information About Subqueries….
Example of Subquery:
Select e.Eno,e.Ename from Employee e where (This is outer query) Ename=
(Select E2.Ename from Employee E2 where E2.Name=’Amit’)(Inner Query Executes first);
2.What is correlated Subquery?(80 % asked in Interview Questions for Tech Mahindra)
Answer:
Correlated query is the query which is executed after the outer query is executed.The outer query is always dependent on inner query.The approach of the correlated subquery is bit different than normal subqueries.In normal subqueries the inner queries are executed first and then the outer query is executed but in Correlated Subquery outer query is always dependent on inner query so first outer query is executed then inner query is executed.Correlated Subqueries always uses operator like Exist,Not Exist,IN,Not IN. (Source-click here)
Example:
Select * from Employee E where Not exist
(Select Department_no From Department D where E.Employee_id=D.Employee_ID);
Execution of query:
Step 1:
Select * from Employee E ;
It will fetch the all employees
Step 2:
The First Record of the Employee second query is executed and output is given to first query.
(Select Department_no From Department D where E.Employee_id=D.Employee_ID);
Step 3:
Step 2 is repeated until and unless all output is been fetched. (Source-Click here)
3.What is faster. In Operator in SQL or Exist in SQL?
Answer:
In Operator is slower than Exist operator.In Operator scans full table and checks the each and every value of the table.Exist operator only checks whether the value is present in the table or not.
4.What is query to calculate second highest salary of the employee using analytical function?
Answer:
We need to use Dense_Rank function to calculate second highest salary:
select * from (Select Dense_Rank() over ( order by salary desc) as Rnk,E.* from Employee E) where Rnk=2;
5.How Can i create table with same structure of Employee table?
Answer:
Following query used to create table with same structure of Employee table:
Create table Employee_1 as Select * from Employee where 1=2;
Click Here to get 20 Most Asked Complex SQL Queries…
6.What are Set operators in SQL?
ANSWER:
Set operators are nothing but the operators which are used to connect two tables and fetch the records from the two tables.We need to follow one condition that the table set 1 columns and table set 2 columns are same and its datatype must be same.SQL Set Operators combines the result of 2 queries or components on to the single result.
Following are Set Operators in SQL:
- Union
- Unionall
- Intersect
- Minus
Click Here to get more information about Set operators…
7.What is Union Operator?(90 % asked in Interview Questions for Tech Mahindra)
Answer:
Union Operator combines the result of 2 or more tables and fetches the results of two select statements.Union operator eliminates the duplicates from the table and fetches the result.For each duplicate row in table only one row is displayed in the result.By considering the performance of SQL using union is not preferable option but if there is situation where user wants to remove the duplicate data from two or more table the use of Union is preferable.
Example:
Select Employee_Num,Employee_name,Department,Salary from Employee_OBIEE;
Union
Select Employee_Num,Employee_name,Department,Salary from Employee_COGNOS;
8.What is difference Between UNION and UNION All?(90 % asked in Interview Questions for Tech Mahindra)
Answer:
Union | Union ALL |
1.Union Set operator is used to fetch the records from 2 different tables which eliminates the duplicate records | 1.Union all Set operator is used to fetch the records from 2 different tables which does not eliminates the duplicate records |
2.Syntax:
Select col1,col2…from table1; Union Select col1,col2…from table2; |
2.Syntax:
Select col1,col2…from table1; Union Select col1,col2…from table2; |
3.For Performance tuning Union operator is not preferable as it takes time to eliminate duplicate records | 3.Union all is preferable operator in Performance tuning. |
9.Which is faster operator Union or union all?
Answer:
Union all is faster than union because it does not have sorting program running inside.The union operator is slower than union all because it removes duplicates from the data.To Remove Duplicate compiler needs to run sorting program and table is scanned full.
So Union all is faster than union operator.
Click HERE TO GET INFORMATION ON UNION AND UNIONALL OPERATOR
10.What is difference between varchar and varchar2 datatype?
Answer:
Varchar can store up to 2000 bytes and varchar2 can store up to 4000 bytes of memory space.Varchar will occupy the space for null values whereas varchar2 can not occupy the space for null values.So varchar2 is good to use not to face performace related problems.varchar2 is faster than varchar datatype.
11.What is Difference Between Row_id and Rownum?
Answer:
ROWID is nothing but the physical address given to that row which is in hexadecimal format.ROWNUM is nothing but the logical sequence given to the row of that column.
Click here to get the information about Row_id and Rownum
12.What is DDL?
Answer:
DDL stands for Data Definition Language.Following are the different DDL statements:
Statement | Description |
CREATE | Creates a new table, a view of a table, or other object in database |
ALTER | Modifies an existing database object, such as a table. |
DROP | Deletes an entire table, a view of a table or other object in the database. |
CLICK HERE TO CHECK EXECUTION OF SELECT STATEMENT STEPWISE
13.Explain different Joins in SQL?
Answer:
Join is nothing but connecting 2 tables to fetch the records from 2 or more different tables.There are following types of joins in SQL:
1.Inner join:
Inner join retreives the records which are common between 2 or more tables.
2.Outer join:
Outer join retrieves the common records from the table as well as uncommon records from Left or right table.
2.1.Left outer join:
When user needs to fetch all data from left table and common records from left and right table then the join is called as left outer join.
2.2.Left outer join:
When user needs to fetch all data from right table and common records from left and right table then the join is called as right outer join.
2.3.Full Outer Join:
When user needs to fetch the data from both the tables and common records from both of the tables.
3.Cross join/Cartesian join:
When each and every record is connected to each and every record from other table then it is called as cross join or Cartesian join.
Click Here to get information about SQL joins..
14.What is Optimizer?
Answer:
Optimizer is nothing but the execution of query in optimum manner.Optimizer is most efficient way of processing the query.SQL parser ,SQL Optimizer and source code generator compiles the SQL statement.
Click Here to get more information about Optimizer..
15.What is Index?What is use of index in SQL?
Answer:
Index is optional structure associated with the table which may or may not improve the performance of Query.In simple words suppose we want to search the topic in to book we go to index page of that book and search the topic which we want.Just like that to search the values from the table when indexing is there you need not use the full table scan.
Indexes are used to improve the performance of the query.
Click here to get more information about indexes..
16. What are types of Indexes?
Answer:
1.Normal index
2.Unique Index
3.Bit Map Index
4.Composite Index
5.B-Tree Index(Oracle considered Normal indexes as B-Tree Indexes)
6.Function Based Index
7.Clustered Index
8.Non-Clustered Index.
17.Can you truncate the records using where condition?
Answer:
We can not use where condition with trucate.
18.What is unique index?
Answer:
To create unique index you must have CREATE ANY INDEX privilege.Here the concept is bit different.User needs to check the values of the table to create unique index.If table contains uniquely identified values in specified column then you should use unique index.Especially while creating the table if we specify the primary key then unique index is automatically created on that column.But for Unique key constraint columns you separately need to do indexing.Kindly make sure that Unique key indexes created on the columns which has unique values only.
CLICK HERE TO GET INFORMATION ON INDEXES..
19.What are views in SQL?Explain types of Views in SQL? (90% asked in Interview Questions for Tech Mahindra)
Answer:
Views:Views are nothing but the logical structure of the table where we can fetch the data from different tables or same table.
There are 2 types of views in Oracle:
1.Simple View:Simple view has been created on only a single table.
2.Complex view:Views which are created using more than 1 table which has joins clauses are known as complex views.
20.What is Materialized View in SQL?(90 % asked in Interview Questions for Tech Mahindra)
Answer:
Materialized view is also logical structure of one or more table in which data is stored physically in the view.Data has been stored physically in materialized view so data retrieval is faster as compare to simple view.
Click here to get more information on materialized views..
Hope You will like this article on Tech Mahindra interview Questions.If you want PDF of this article Kindly comment in comment section..
Nice.. And very useful
Thanks nagababuuu
Nice , can you please send PDF with more SQL interview questions
Hey vinod
I have sent youthe PDF for SQL interview questions..Kindly check.
Hello sir,it is very usefull can you please send pdf for SQL interview questions
Yeah Laxmi sent you the interview questions… 🙂
Hello sir,it is very usefull. Could you please send pdf for SQL interview questions
my mail id- bishalkumar156@gmail.com
Kindly check your inbox.
dear sir
please send sql and plsql interview questions and also performance tuning
Hi Pethilraj,
I sent you PDF for SQL interview questions on your mail..
Kindly check following link for PL SQL and SQL tuning questions :
Tuning :
http://www.complexsql.com/sql-performance-indexing-in-sql-types-of-indexes-in-sql/
PL SQL :
http://www.complexsql.com/plsql-interview-questions/
Thanks,
Amit S
Please send me SQL Interview question ashutosh.iilm@gmail.com
Hi,
Kindly check your mailbox.I have sent you the interview questions!!
Regards and thanks,
Amit S
Can you please share more PL/SQL interview questions to my email id soni193rahul@gmail.com
You can refer links :
http://www.complexsql.com/plsql-interview-questions/
http://www.complexsql.com/stored-procedure-interview-questions/
Please send me SQL Interview question and also the PDF of this article.
sushreesangita511@gmail.com
I have sent you interview questions on your mail id!!!
super amit sir ,,,can u send the frequent interview questions to me
I have sent you Interview Questions!!!
HI Please share me SQL&PL/SQL interview questions and performance Tuning PDF Format
bsr.sunil2019@gmail.com
Sure Sunil!!
I will send you interview questions!!
Very helpful – please email PDF. thank you
Thanks LAxmi Sent you interview questions!!
Hello Amit,
Please forward the document/ pdf’s related to interview questions.
Sure Prakash!! I sent you SQL Interview Questions for Tech Mahindra to your mail id.
Really ,it is very useful for my Etl interview.
Can you send me the pdf of Interview questions for sql and Etl.
Thanks in Advance Sir…!!!
sure Tejashri..
Kindly check your inbox..
Hi Amit,
The information is very useful and clearly explained.
Please send me the pdfs for SQL & PLSQL interview questions.
Thanks.
Thanks Mohammed..
Kindly check inbox for more information.
Sir, Thanks in Advance Please Send me the PDF For SQL And Advance SQL Interview Questions
I sent you SQL and PLSQL interview questions..
can you please sent me also sql and plsql Advanced interview questions.
Sure Ashwani..Sent you interview questions 🙂
hello amit,
Can u plz share me some interview questions for sql, pl sql, unix asked in tech mahindra. It will be great.
Kindly check your inbox for the same..
please provide pdf file
Hi Rakesh,
I have sent you important interview questions.
Regards,
Amit Shiravadekar
hi pls can u send me the sql interview questions. thank you very much
Sure Jo
Hello Amit,
This information has helped me to learn a lot in a day. Please send me the PDF of interview questions.
My mail id is abhishekraikhelkar@gmail.com
Hi Abhishek,
I sent you interview questions for SQL.
Regards,
Amit S
Hi Amit
Pleased send me the interview questions
Thanks
Sure Anjali..Check your inbox 🙂