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 for 'Sql' - 49 question(s) found - Order By Newest

next 30
Frequently asked in Cognizant ( Based on 2 feedback )
  Q1. 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


  Q2. What is the use of Transient Keyword ?Core Java
Ans. It in Java is used to indicate that a field should not be serialized.

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

   Like         Discuss         Correct / Improve     java   oops   serialization   transient   java keywords     Asked in 39 Companies      intermediate        frequent

Try 2 Question(s) Test


 Q3. What are temp tables ?
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


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

or

What is self Join and What is it's purpose ?
Database
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     Asked in 26 Companies      basic        frequent


 Q5. Is there any schema in mongo DB ?MongoDB
Ans. There is schema in mongo-db but the schema need not to be defined before creating collection.

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

   Like         Discuss         Correct / Improve     mongodb  nosql  bigdata     Asked in 1 Companies


 Q6. Difference between Inner and Outer Join ?Database
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     Asked in 4 Companies      basic        frequent


 Q7. What is a Cursor ?Database
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     Asked in 5 Companies      basic        frequent


 Q8. Does SQL allow null values ? Can we use it within Where clause ?
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


 Q9. Write an SQL to find all records having all upper case alphanumeric characters in a field ?
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


 Q10. Write an SQL to find all records having all numeric characters in a field ?
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


 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


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: