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

Search Interview Questions


 2807 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

   



Interview Questions and Answers for 'Database' - 103 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


Frequently asked to experienced developers. Recently asked in many US interviews.
 Q2. What is database deadlock ? How can we avoid them?Database
Admin
info@buggybread.com
Ans. When multiple external resources are trying to access the DB locks and runs into cyclic wait, it may makes the DB unresponsive.

Deadlock can be avoided using variety of measures, Few listed below -

Can make a queue wherein we can verify and order the request to DB.

Less use of cursors as they lock the tables for long time.

Keeping the transaction smaller.

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


   Like      Discuss      Correct / Improve     java   database   architecture     MSCI  Vudu  Bank Of America  Sears      expert        frequent


 Q3. What is JDBC? Describe the steps needed to execute a SQL query using JDBC.Database
Anonymous
Ans. The JDBC is a pure Java API used to execute SQL statements. It provides a set of classes and interfaces that can be used by developers to write database applications.

The steps needed to execute a SQL query using JDBC:

1. Open a connection to the database.
2. Execute a SQL statement.
3. Process th results.
4. Close the connection to the database.

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

   Like      Discuss      Correct / Improve     java   jdbc   db connectivity     Nucleus Software Exports  Caprus IT      basic        frequent


 Q4. What things you would care about to improve the performance of Application if its identified that its DB communication that needs to be improved ?Solution
Admin
info@buggybread.com
Ans. 1. Query Optimization ( Query Rewriting , Prepared Statements )

2. Restructuring Indexes.

3. DB Caching Tuning ( if using ORM )

4. Identifying the problems ( if any ) with the ORM Strategy ( If using ORM )

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

   Like      Discuss      Correct / Improve     java   db   database   hibernate   orm   at&t   overstock.com   performance improvement   architecture   technical lead   architect      intermediate


 Q5. If you are given a choice to implement the code to either Insert a Record or Update if already exist, Which approach will you follow ?

1. Insert into the DB Table. If exception occurs, update the existing record.
2. Check if the record exists and update it if it exists, If not insert a new record.
Solution
admin
info@buggybread.com
Ans. In first case, there would be 2 DB calls in worst case and 1 in best case. In 2nd approach there will be always 2 DB calls.

Decision on the approach should depend on the following considerations -

1. How costly is the call to DB ? Are we using indices , hibernate etc

If calls to DB are costly , 1st approach should be the choice.

2. Exception Book keeping load upon exception.

The benefit of saving 1st call in approach 1 should be bigger than the Book keeping for the exception.

3. Probability of the exception in first apparoach.

If the DB Table is almost empty, it makes sense to follow Approach 1 as majority of the 1st calls will pass through without exception.

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

   Like      Discuss      Correct / Improve     database   insert-update   db exceution plan   db strategy   design   architecture   technical lead


Frequently asked to fresh graduates.
 Q6. What is ACID ?Database2016-11-04 08:09:44

Ans. ACID stands for Atomicity, Consistency, Isolation, Durability is a set of properties of database transactions.

Atomicity means all or nothing. i.e parts of a transaction shouldn't commit if any one of them fails. Either the whole transaction should succeed or it should be complete rollback.

Consistency means that any transaction should lead database from one stabe state to another.

Isolation means that the execution of transaction results in a system state that would be obtained if transactions were executed serially.

Durability means that when a transaction is committed it forms the permanent state of database.

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

   Like      Discuss      Correct / Improve     database  acid     CapitalOne   Tata Consultancy (TCS)  SilverRail Technologies  A9.com  Oracle  Sirius Computer Solutions      Intermediate

Try 1 Question(s) Test


 Q7. What is the use of @GeneratedValue annotation in Hibernate?Hibernate
Admin
info@buggybread.com
Ans. This annotation is added to the auto increment column with the strategy to increment the column value. Usually this is added to the surrogate primary key column and specified with the Database Sequence.

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

   Like      Discuss      Correct / Improve     hibernate   hibernate annotations   @generatedvalue   database sequence


  Q8. 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


 Q9. What is connection pooling?Database
Admin
info@buggybread.com
Ans. It's a technique to allow multiple clients to make use of a cached set of shared and reusable connection objects providing access to a database or other resource.

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

   Like      Discuss      Correct / Improve     java   jdbc   db connectivity   connection pooling   architecture     Cognizant (CTS)  IGATE  eMeasurematics      basic        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. 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


 Q11. 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


 Q12. 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


 Q13. 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


 Q14. 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


 Q15. 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


 Q16. 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


 Q17. What is the advantage of JPA ?Database
Admin
info@buggybread.com
Ans. Its a specification that guides the implementation of ORM frameworks. Implementations abiding by the specification would mean that one can be replaced with other in an application without much hassle. Only the Features that are added over the specification needs to be taken care of if any such change is made.

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

   Like      Discuss      Correct / Improve     jpa   hibernate   orm   technologies


 Q18. 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


 Q19. 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



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. 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


 Q21. 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)


 Q22. 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


 Q23. 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


 Q24. 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


 Q25. 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


 Q26. 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


 Q27. What are the advantages of using distributed database management system ?Database2016-11-30 16:05:24

Ans. Reliability and Continuity if some of the sites goes down.Easy Scaling up and Down as sites can be added or removed without impacting business continuity.

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

   Like      Discuss      Correct / Improve     dbms  database management system  distributed database management system     Elsevier


 Q28. When do we generally get this database error - integrity constraint violated - parent key not found ?2016-07-12 08:40:57

Ans. This error most likely will be thrown during an insert statement, while inserting a value within a foreign key column which doesnt exist within the Parent column. For example - Trying to add a dept number reference within a Employee Table when the Dept doesnt exist in the Dept Table.

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

   Like      Discuss      Correct / Improve     database  integrity constraint error  integrity constraint violated


 Q29. What is a Database Procedure ?Database2016-10-18 11:27:59

Ans. Stored procedures are a batch of SQL statements along with programming constructs ( if else, loops etc ) and stored as a single program that can be called by different clients and hence reused.

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

   Like      Discuss      Correct / Improve     database  stored procedure     Cognizant (CTS)      basic        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q30. What is a Database sequence ?Database2016-10-18 11:30:07

Ans. Its a feature wherein database creates unique values incremental values to be stored as primary key for the table.

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

   Like      Discuss      Correct / Improve     database   sequence     Cognizant (CTS)


  Q31. What is a Database Trigger ?Database2016-10-18 11:31:17

Ans. A trigger is a special kind of stored procedure that automatically gets executed upon an event in the database server.

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

   Like      Discuss      Correct / Improve     database   trigger     Cognizant (CTS)  Acclaris  RedMane  Oracle  Mediaocean  Monsanto  Synchronoss  Unbounded Solutions  Clover  Jabong.com      basic        frequent


 Q32. Have you heard about the external table feature of Oracle ?Database2016-10-18 11:48:05

Ans. The external tables feature is a complement to existing SQL Loader functionality. It enables to access data in external sources as if it were in a table in the database. We have used it few times for replicating tables across different database systems.

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

   Like      Discuss      Correct / Improve     external table oracle     Infosys        rare


 Q33. How to count total number of tables in database ?Database2016-10-18 14:13:31

Ans. SELECT COUNT(*) FROM information_schema.tables

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

   Like      Discuss      Correct / Improve     database query     MagicBricks


 Q34. There is a Table Student having Student Id, Name and Total Marks. Can you please write an SQL that will display the maximum marks obtained by a student ?Database2016-10-18 14:21:04

Ans. SELECT MARKS FROM STUDENT ORDER BY MARKS DESC LIMIT 1;

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

   Like      Discuss      Correct / Improve     database query     MagicBricks


 Q35. What is CRUD ?Database2016-06-13 10:34:03

Ans. CRUD stands for "Create, read, update and delete" are the basic functions of persistence.

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

   Like      Discuss      Correct / Improve     CRUD  Persistence  Database  Database Operations     Logica  JP Morgan  FastPay      Basic        frequent


 Q36. When do we generally get the database error - Unique Constraint Violated ?2016-07-12 08:43:38

Ans. This error can result either on an insert, update or delete when any change in data results in duplicate record or subset of it having unique constraint on record or its subset. For example - If we have a unique constraint on a combination of columns and then trying to insert duplicate column values.

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

   Like      Discuss      Correct / Improve     database  Unique Constraint error  Unique Constraint violated


 Q37. What are some alternates to keeping Audit Tables ?Database2016-07-14 14:24:37

Ans. Audit Tables generally stores Raw information to be reviewed in case of problems or determining impact. If Database space is an issue , and the audit information is rarely retrieved, one design could be to use compressed file system.

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

   Like      Discuss      Correct / Improve     databases   audit tables   raw transaction information storage     Sapient


 Q38. What is the purpose of Commit and Rollback in Databases ?Database2016-07-14 14:28:55

Ans. When a DML is executed, the changes only stays in session and still not pushed to DB Tables, Commit is used to push those changes to the Tables.

In case we realize that we don't want to commit those changes and would like to ignore them, we can use rollback.

For example - You may like that for a banking transaction you would like to update the account balance only if the debit or credit record was correctly inserted, so you may like to encapsulate both DML's - insert for transaction and update for balance in a single transaction and would only commit if both succeeds else rollback.

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

   Like      Discuss      Correct / Improve     databases  commit  rollback     Amdocs  The Bank of New York Mellon (BNY Mellon)      Basic


 Q39. How to Bulk upload the data into Oracle database?Database2016-10-21 12:36:26

Ans. We can use external table feature of Oracle.

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

   Like      Discuss      Correct / Improve          HCL Technologies      Intermediate



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q40. Write an SQL Statement to add a foreign key constraint in oracle ?Database2016-11-08 14:27:31

Ans. ALTER TABLE <Table_Name> ADD CONSTRAINT <Constraint_Name> FOREIGN KEY (<Column_Name>) REFERENCES <Foreign_Table>(<Foreign_Column>);

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

   Like      Discuss      Correct / Improve     database  add foreign key constraint


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: