Database - Interview Questions and Answers for 'Sql' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Interview Questions


 2796 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Database - Interview Questions and Answers for 'Sql' - 44 question(s) found - Order By Newest

next 40
Frequently asked in Cognizant ( Based on 2 feedback )
  Q1. What are Inner , Outer , Left and Right Joins in SQL ?Database2017-01-09 13:07:55

Ans. Inner join is the intersection of two tables on the condition defined by the where clause i.e will get records from both tables matched by a column.

Outer join is the union of two tables i.e will get all records from both tables and will put null in the columns where related records are not present.

Left Outer join is the left union of two tables i.e all records from the table on the left and values from the right table for related records else null for the columns from right table.

Right Outer join is the right union of two tables i.e all records from the table on the right and values from the left table for related records else null for the columns from left table.

 Help us improve. Please let us know the company, where you were asked this question :   


   Like      Discuss      Correct / Improve     sql  inner join  outer join  right join  left join     EPAM  Antra  MSCI  HCL Technologies  Cognizant (CTS)  Morgan Stanley  Wipro  Infosys  Accenture  IBM  PayPal  A9.com  Curriculum Associates  Gold Coast IT  Kobie Marketing  Hybris  Aptroid Technologies  E2open  IGATE  SnapDeal  Verilogue  Span Infotech      basic        frequent


  Q2. What is a self Join and give an example of a self Join ?

or

What is self Join and What is it's purpose ?
Database2016-06-30 20:13:35

Ans. When a Table Join itself , it's a Self Join. For example - we like to know the pair of department names where first dept has lesser employees than the later.

Select D1.name , D2.name from Dept D1, Dept D2 where D1.employee_count < D2.employee_count

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql  joins  self join  self-join  Pair of employee names with first having lesser salary than later  Pair of department names where first dept has lesser employees than the later     Accenture  West Monroe Partners  Oracle  eBay  Impetus Technologies  Bank of America  Fannie Mae  Wize Commerce  Kleward Consulting  Pyramid Consulting  Interra Information Technologies  Trigent Software  Xtreme Media  IGATE  Nagarro  Six Sigma  Nityo Infotech  Fujitsu  BlazeClan  Twist Bioscience  Invoyent  Cognizant (CTS)  i2c  Capgemini   Blazeclan      basic        frequent


 Q3. Difference between Inner and Outer Join ?Database
Admin
info@buggybread.com
Ans. Inner join is the intersection of two tables on a particular columns whereas Outer Join is the Union of two tables.



 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   joins   inner join   outer join     Hewlett Packard (HP)      basic        frequent


 Q4. What is a Cursor ?Database
Admin
info@buggybread.com
Ans. It's a facility that allows traversal over the records pulled from a table or combination of tables. Its like iterator in Java.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     databases   sql   cursors   packages     Jade Global  Paychex  Credence Analytics  CMSS Pvt Ltd  BlacKMagic Design Pte Ltd      basic        frequent


 Q5. What are temp tables ?
Admin
info@buggybread.com
Ans. These are the tables that are created temporarily and are deleted once the Stored Procedure is complete.

For example - we may like to pull some info from a table and then do some operations on that data and then store the output in final output table. We can store the intermediary values in a temp table and once we have final output with us, we can just delete it.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database   sql   temp tables   tables


 Q6. Does SQL allow null values ? Can we use it within Where clause ?
Admin
info@buggybread.com
Ans. Yes , we can have null values for columns in SQL. Null value represent that the columns value is unknown or haven't been filled. Yes, We can use it within where clause to get the rows with null values.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   sql null values   sql where clause   databases


 Q7. Write an SQL to find all records having all upper case alphanumeric characters in a field ?
admin
info@buggybread.com
Ans. Select * from Table where field = upper(field)

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database


 Q8. Write an SQL to find all records having all numeric characters in a field ?
admin
info@buggybread.com
Ans. Select * from Table where isnumeric(field) = 1;

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database


 Q9. Do you know of any DB statement that can be used if we would like to insert multiple rows into a table ? Database
Admin
info@buggybread.com
Ans. We can use INSERT ALL.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database   insert   dml statement   sql



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. What things you will look for if you get following exception while making DB call ?

table or view does not exist
Database
Admin
info@buggybread.com
Ans. First will check if the table or view actually exist in the DB

If it does , Will make sure to see that the application has rights on the schema that holds the respective Table.

Will then make sure that we have prefixed the schema with the table name while accessing it.

Will then make sure that its not DB Cache that's causing it as the table DDL might have been created recently.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database   oracle   technical lead


 Q11. What's the benefit for specifying constraints like Not Null , Primary Key explicitly instead of specifying it against the column ?Database
Admin
info@buggybread.com
Ans. In case we specify them explicitly we can have control over constraint name as otherwise they will be system generated. It provides an ease in case we plan to drop the constraint in future.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q12. How can we disable a constraint ?Database
Admin
info@buggybread.com
Ans. alter table
table_name
DISABLE constraint
constraint_name;

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q13. Can we have foreign key reference to a non primary key column ?Database
Admin
info@buggybread.com
Ans. Yes, but the respective key in the foreign table should be declared Unique.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database   oracle     IRIS Software  Tata Consultancy (TCS)


 Q14. What should be done for auto generating primary key id in a table ?Database
admin
info@buggybread.com
Ans. We need to create a sequence.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q15. Which constraint cannot be specified as an explicit constraint and should be specified with the column only ?Database
Admin
info@buggybread.com
Ans. NOT NULL

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   oracle   database   ddl   constraint   table creation


 Q16. How to know the structure of a Table in Oracle ?Database
Admin
info@buggybread.com
Ans. DESC

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q17. How to know the constraints on a Table in Oracle ?Database
Admin
info@buggybread.com
Ans. SELECT *
FROM user_constraints
WHERE table_name = ''

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q18. How to know the default column value of a Table in Oracle ?Database
Admin
info@buggybread.com
Ans. Select DATA_DEFAULT
from DBA_TAB_COLUMNS
where TABLE_NAME = '' and COLUMN_NAME='';

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql   database   oracle


 Q19. Difference between relational databases and NoSQL databases ?Database2016-12-13 11:06:42

Ans. https://www.mongodb.com/scale/nosql-vs-relational-databases

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database management  nosql database  relational database     Alibaba        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. With a Table employee having columns Id,Name,ManagerEmployeeId, Write a SQL to find the Manager with maximum number of employees ?Database2016-12-21 09:44:31

Ans. Select Name from EMPLOYEE where ID in (Select ManagerEmployeeId from EMPLOYEE
Group By ManagerEmployeeId
order by count(Id)
LIMIT 1)

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database  sql     Computer Sciences Corporation (CSC) India


 Q21. What do you make out of this error

org.hibernate.exception.ConstraintViolationException: could not insert: [<Entity>]
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (<Constraint Name>) violated

and how would you go about debugging it ?
Database2017-03-22 13:12:50

Ans. Application is unable to insert a record as it violates a unique constraint.

The exception states the constraint and Table can be located by the Entity mapping. So I will go to the DB and will first check to which all columns the unique constraint applies. And then I will go and check the code and logs to see how come the duplicate column values were attempted to be inserted when they were not supposed to be.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     ConstraintViolationException  SQLIntegrityConstraintViolationException


 Q22. If Table A has 100 records and Table B has 50 records , how many records will the equi join of Table generate ?SQL2017-07-14 17:59:56

Ans. It depends on the join condition.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     equi join  sql join  database  sql


 Q23. If Table A has 100 records and Table B has 50 records , how many records will the left join of Table A with Table B generate ?SQL2017-07-14 18:00:37

Ans. 100 records

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database  sql  sql joins   left join


 Q24. If Table A has 100 records and Table B has 50 records , how many records will the right join of Table A with Table B generate ?SQL2017-07-14 18:01:01

Ans. 50 records

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database  sql  sql joins   right join


 Q25. If Table A has 0 records and Table B has 50 records , how many records will the equi join of Table generate ?SQL2017-07-14 18:01:50

Ans. 0 records

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database  sql  sql joins   equi join


 Q26. Write a SQL to remove records with a duplicate field in a Table ?Database2017-08-17 10:59:44

 This question was recently asked at 'Sofi'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql     Sofi


 Q27. How different is the Search algorithm when we query Cassandra Tables and When we query Oracle Tables ?Cassandra2017-08-18 09:40:40

Ans. Relational Database uses linear search if we don't query using indices. Performance for linear search is O(n). If indices have been used , relational database uses binary search. Performance for binary search is O(Log n).

Casandra uses hash search. Performance for Hash Search is O(1).

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     cassandra vs oracle  nosql vs relational  search algorithm


 Q28. Which of the following databases - Cassandra / Oracle - provides more flexibility about querying the database ?Database2017-08-18 09:44:08

Ans. Oracle as it is not modeled for a particular query or set of queries.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     Cassandra  Nosql database  nosql vs relational database


 Q29. Which is the best NoSql Database for Performance ?NoSql2017-08-19 19:32:09

Ans. Possible Answer - doument base - monogodb

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     Nosql Database



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q30. Write a SQL to find 2nd Max value in a Table.Database2017-08-24 13:56:33

Ans. SELECT MIN(FIELD) FROM (SELECT TOP 2 FIELD FROM TABLE ORDER BY FIELD DESC)

or

SELECT MAX(FIELD) FROM TABLE WHERE FIELD NOT IN (SELECT MAX(FIELD) FROM TABLE)

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql


 Q31. Write a SQL to find max salary by DeptSQL2017-08-26 12:34:28

Ans. SELECT MAX(SALARY),DEPT FROM EMPLOYEE GROUP BY DEPT

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     


 Q32. Write a SQL to display all duplicate names from Employee TableSQL2017-08-26 12:38:32

Ans. SELECT * FROM EMPLOYEE A WHERE A.ROW_ID IN (SELECT MAX(ROW_ID) FROM EMPLOYEE b WHERE A.NAME = B.NAME )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     


 Q33. Write an SQL to get Employees who are also ManagersSQL2017-08-26 12:42:49

Ans. SELECT A.NAME FROM EMPLOYEE A, EMPLOYEE B WHERE A.ID = B.MANAGER_ID

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     


 Q34. Is there any schema in mongo DB ?MongoDB2017-08-27 20:30:13

Ans. No It's schema less

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     mongodb  nosql  bigdata     Tapp Me


 Q35. What is Left Outer Join ?Database2018-01-05 15:25:44

 This question was recently asked at 'NIIT Tech'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database   database joins   left outer join  sql     NIIT Tech


 Q36. Describe SQL JoinsDatabase2018-02-08 00:11:24

 This question was recently asked at 'Mindtree'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql joins  sql     Mindtree


 Q37. What are different in memory data structures that are used in No Sql Database ?NoSql Database2018-04-14 10:46:28

 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     


 Q38. What are different types of No Sql Databases ?NoSql2018-04-14 10:46:56

Ans. graph based
column based
document based

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     


 Q39. Difference between Left and Inner Join ?SQL2018-05-24 13:24:47

 This question was recently asked at 'Canopy Tax'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sql     Canopy Tax



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q40. Write SQL to get all members and the count of books they have checked out , even the ones that haven't checked out anything.SQL2018-06-30 13:43:26

 This question was recently asked at 'Canopy Tax'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     database  sql     Canopy Tax


next 40


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus  

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: