Monday, 2 April 2018

Sql Interview questions

Q: Can we perform DML in view?
Answer: Yes, Possible but only when we create the View of One table, Means for Simple View you can perform Insert,Update and Delete also but in Complex View you Can't Means a View which is created by More then two Tables. And one more thing Views have no Physical appearance so it doesn't take any memory.

Q: Can we use pocedues in function?
Answer: No.

Q: Can we use functions in pocedues?
Answer: Yes.

Q: Can we perform DML in functions?
Answer: No, Function allows only SELECT statement in it.

Q: Difference between stored procedures and functions?
Answer: Following are some difference between stored procedures and functions:
1. Function must return a value but in Stored Procedure it is optional( Procedure can return zero or n values).
2. Functions can have only input parameters for it whereas Procedures can have input/output parameters .
3. Functions can be called from Procedure whereas Procedures cannot be called from Function.
4. Procedure allows SELECT as well as DML(INSERT/UPDATE/DELETE) statement in it whereas Function allows only SELECT statement in it.
5. Procedures can not be utilized in a SELECT statement whereas Function can be embedded in a SELECT statement.
6. Exception can be handled by try-catch block in a Procedure whereas try-catch block cannot be used in a Function.
7. We can go for Transaction Management in Procedure whereas we can't go in Function.

Q: What is triggers in database?
Answer: A database trigger is special stored procedure that is run when specific actions occur within a database.  Most triggers are defined to run when changes are made to a table’s data.  Triggers can be defined to run instead of or after DML (Data Manipulation Language) actions such as INSERT, UPDATE, and DELETE.

No comments:

Post a Comment