Common SQL Interview Questions for Freshers
A primary key is a column in a table whose values uniquely identify the rows in the table. The primary key is chosen from this list of candidates based on its perceived value to the business as an identifier.
A primary key value:
- Must uniquely identiy the row;
- cannot have NULL values;
- Should not change over the time; and
- Should be as short as possible.
One can describe a
candidate key as a super key that contains only the minimum number of columns necessary to
determine uniqueness.
An alternate
key is any candidate key that is not the primary key.
Alternate keys are sometimes referred to as secondary keys.
What
is the definitions between stored procedures and functions?
1. Should return atleast one output parameter.Can return more than one parameter using OUT argument.
2. Parsed and compiled at runtime.
3.Cannot affect the state of database.
4.Can be invoked from SQL statement e.g. SELECT.
5. Functions are mainly used to compute values.
Procedure:
1. Doesn't need to return values but can return value.
2.Stored as a pseudo-code in database i.e. compiled form.
3.Can affect the state of database using commit etc.
4.Cannnot be invoked from SQL statements e.g. SELECT.
5.Procedures
are mainly used to process the tasks.
Comments