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

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 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 - Order By Rating

   next 30
 Q61. What is a unique constraint ?Database
Ans. Unique constraint ensures that a columns or combination or columns are always unique in a table and hence doesn't allow null or duplicates to be entered for the column or combination of columns.

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

   Like         Discuss         Correct / Improve     unique constraint


 Q62. What is a check database constraint ?Database
Ans. Constraint specifies the values allowed in one or more columns of every row of a table.

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

   Like         Discuss         Correct / Improve     database constraint


 Q63. What are the different database constraint types ?Database
Ans. Not Null
Unique
Primary Key
Foreign Key
Check Constraint

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

   Like         Discuss         Correct / Improve          Asked in 1 Companies


 Q64. 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 ?
Database
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


 Q65. Does null and empty value for a column in Table means same ?Database
Ans. No.

Null value means that the value is yet to be assigned or need not be assigned whereas empty value means that the blank value has already been assigned once. Null is the default for the null able columns that hasn't be assigned any value.

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

   Like         Discuss         Correct / Improve     


 Q66. Where the prepared Statement object creating - In Java application or DB ?Database
Ans. Prepared Statement objects are created and cached at database level.

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

   Like         Discuss         Correct / Improve     Prepared statements     Asked in 1 Companies

Try 1 Question(s) Test


 Q67. What are the benefits of using prepared statements ? Does that benefit extend only if similar prepared statements are used within a application or it extends even with multiple applications having similar prepared statement ?Database
Ans. Prepared Statements helps in reuse of database execution plan which can be cached at Database level and hence helps achieving faster execution and performance. As cached ps objects are creating at Database level and not application level, the use and benefit extends across multiple applications.

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

   Like         Discuss         Correct / Improve     Prepared statements  benefits of prepared statements     Asked in 1 Companies

Try 1 Question(s) Test


 Q68. What are the benefits of using Prepared statements ?Database
Ans. 1. Precompilation , DB-side caching and reuse of same execution plan leads to overall faster execution.

2. Automatic prevention of SQL injection attacks by escaping special characters

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

   Like         Discuss         Correct / Improve     Prepared statements  benefits of prepared statements     Asked in 1 Companies

Try 1 Question(s) Test


 Q69. Can the foreign key column have null values ?Database
 This question was recently asked at 'Volkswagen It services'.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          Asked in 1 Companies


 Q70. What are the methods to connect to database in Java ?Database
Ans. JDBC ( Java Database Connectivity ),ODBC (Open Database Connectivity), Hibernate, JPA ( Java Persistence API ), JOOQ,MyBatis

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

   Like         Discuss         Correct / Improve     database connection  jdbc  ORM  Hibernate     Asked in 1 Companies


 Q71. Create a Table with 2 Columns and Insert a row into itDatabase
Ans. CREATE TABLE TABLE_NAME (
ID NUMBER PRIMARY KEY,
NAME VARCHAR(50) NOT NULL,
);

INSERT INTO TABLE_NAME(ID, NAME) VALUES(1, "Abc");

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

   Like         Discuss         Correct / Improve     ddl  dml  create table  insert records into table     Asked in 1 Companies


 Q72. How should we handle errors while writing or accessing Stored Procedures?Database
Ans. Store Procedure returns the error code. Moreover we can put the call withing try block and catch SQL Exception.

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

   Like         Discuss         Correct / Improve     stored procedure  exception handling


 Q73. What actions you take if there is an issue related to Database server ?Support
Ans. We involve DBA and try to solve it through them. By the time they are solving it , we keep the stake holders informed regarding the progress.

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

   Like         Discuss         Correct / Improve     database  database server  production support


 Q74. Which interface is responsible for transaction management in JDBC ?Database
Ans. Connection Interface

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

   Like         Discuss         Correct / Improve     jdbc


Frequently asked in Cognizant ( Based on 2 feedback )
  Q75. What are Inner , Outer , Left and Right Joins in SQL ?Database
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     Asked in 24 Companies      basic        frequent


  Q76. What is database Normalization ?Database
Ans. https://en.wikipedia.org/wiki/Database_normalization

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

   Like         Discuss         Correct / Improve     normalization  database     Asked in 35 Companies      intermediate        frequent


 Q77. With a Table employee having columns Id,Name,ManagerEmployeeId, Write a SQL to find the Manager with maximum number of employees ?Database
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     Asked in 1 Companies


 Q78. How to delete duplicate elements in a table ?Database
Ans. DELETE FROM TABLE WHERE ROW_NUM NOT IN ( SELECT MAX(ROW_ID) FROM TABLE GROUP BY DUPLICATE_FIELD )

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

   Like         Discuss         Correct / Improve          Asked in 3 Companies


 Q79. Difference between relational databases and NoSQL databases ?Database
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     Asked in 1 Companies        frequent


 Q80. Difference between JDBC and Hibernate ?Database
Ans. JDBC is a standard Java Api for Database communication whereas Hibernate is an ORM framework that uses JDBC to connect with Database.

Hibernate is another layer of object table mapping over JDBC that provide a database independent, object oriented and an efficient way of database communication.

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

   Like         Discuss         Correct / Improve     JDBC  Hibernate  JDBC vs Hibernate     Asked in 3 Companies


 Q81. What are the advantages of using distributed database management system ?Database
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     Asked in 1 Companies


 Q82. What is Dirty read in Database Transactions ?Database
Ans. A dirty read occurs when a transaction is allowed to read data from a row that has been modified by another running transaction but not yet committed.

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

   Like         Discuss         Correct / Improve     database transaction     Asked in 8 Companies


 Q83. Write an SQL Statement to add a foreign key constraint in oracle ?Database
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


Frequently asked to fresh graduates.
 Q84. What is ACID ?Database
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     Asked in 7 Companies      Intermediate

Try 1 Question(s) Test


 Q85. How to Bulk upload the data into Oracle database?Database
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          Asked in 1 Companies      Intermediate


 Q86. 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 ?Database
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     Asked in 1 Companies


 Q87. How to count total number of tables in database ?Database
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     Asked in 1 Companies


 Q88. Have you heard about the external table feature of Oracle ?Database
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     Asked in 1 Companies        rare


  Q89. What is a Database Trigger ?Database
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     Asked in 10 Companies      basic        frequent


 Q90. What is a Database sequence ?Database
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     Asked in 1 Companies


previous 30   next 30

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: