Interview Questions and Answers for 'Sql' | 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 Newest

next 30
 Q11. Do you know of any DB statement that can be used if we would like to insert multiple rows into a table ? Database
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


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

table or view does not exist
Database
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


 Q13. What's the benefit for specifying constraints like Not Null , Primary Key explicitly instead of specifying it against the column ?Database
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


 Q14. How can we disable a constraint ?Database
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


 Q15. Can we have foreign key reference to a non primary key column ?Database
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     Asked in 2 Companies


 Q16. What should be done for auto generating primary key id in a table ?Database
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


 Q17. Which constraint cannot be specified as an explicit constraint and should be specified with the column only ?Database
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


 Q18. How to know the structure of a Table in Oracle ?Database
Ans. DESC

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

   Like         Discuss         Correct / Improve     sql   database   oracle


 Q19. How to know the constraints on a Table in Oracle ?Database
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


 Q20. How to know the default column value of a Table in Oracle ?Database
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


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


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


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


 Q24. If Table A has 100 records and Table B has 50 records , how many records will the equi join of Table generate ?SQL
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


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


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


 Q27. If Table A has 0 records and Table B has 50 records , how many records will the equi join of Table generate ?SQL
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


 Q28. Write a SQL to remove records with a duplicate field in a Table ?Database
 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     Asked in 1 Companies


 Q29. How different is the Search algorithm when we query Cassandra Tables and When we query Oracle Tables ?Cassandra
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


 Q30. Which of the following databases - Cassandra / Oracle - provides more flexibility about querying the database ?Database
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


 Q31. Which is the best NoSql Database for Performance ?NoSql
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


 Q32. Write a SQL to find 2nd Max value in a Table.Database
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


 Q33. Write a SQL to find max salary by DeptSQL
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          Asked in 1 Companies


 Q34. Write a SQL to display all duplicate names from Employee TableSQL
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     


 Q35. Write an SQL to get Employees who are also ManagersSQL
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     


 Q36. What is Left Outer Join ?Database
Ans. It returns all the rows form the left table and matches the rows in both tables.

 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     Asked in 2 Companies


 Q37. Describe SQL JoinsDatabase
Ans. Oracle having following types of joins these are also called 8i joins. There are:

1. Equi (or) Inner join
2. Non Equi join
3.Self join
4.Outer join

Oracle also support the 9i (or) ANSI standard joins.There are:

1.Inner join
2.Left outer join
3.Right outer join
4.Full outer join
5.Natural join

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

   Like         Discuss         Correct / Improve     sql joins  sql     Asked in 2 Companies


 Q38. What are different in memory data structures that are used in No Sql Database ?NoSql Database
 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     


 Q39. What are different types of No Sql Databases ?NoSql
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     


 Q40. Difference between Left and Inner Join ?SQL
 This question was recently asked at 'Canopy Tax,Cogent Infotech Corp'.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     Asked in 2 Companies


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: