Tuesday, January 26, 2010

SQL InterviewQuestions Part2

11) what is a constraint?
a) A constraint is a property which is assigned to a column or set of columns in a table. There are 5 types of constraints
Primary key, Unique key, Foreign Key, Check, Not Null

12) What is an entity integrity?
a) This ensures that there can not be duplicate rows in a table

13) What is a Trigger?
a) A trigger is a special of stored procedure which will be executed
automatically in place of or after data modifications. There are 2 types of triggers
After triggers: This is the trigger which will be executed automatically after the statement which triggered it completes
Instead of Triggers This is the trigger which will be executed automatically in place of triggering statement

14) How many after triggers we can crate for a table?
a) We can create any number of after triggers for each Insert, Update, Delete operations on a table

15) How many Instead of triggers can be created for a table?
a) Only one for each Insert, Delete, Update operations

16) Can a trigger be encrypted?
a) Yes.

17) what is the stored procedure used to set the order of after triggers?
a) sp_settriggerorder

18) can we create after triggers on a view?
a) No

19) what is a view?
a) A view is a virtual table which contains columns from one or more tables.

20) what are the advantages of views?
a) 1. It provides security. means if a view is created on a table then the users can access only those columns which are there in view. they cannot access all the columns
2. It simplifies query execution means a complex query can be stored in the form of a view and view can be accessed using a simple query.

No comments: