Вы находитесь на странице: 1из 10

Q1. Explain Collation?

Ans. It is a set of rules that is used to determine that how character data can be
compared and sorted.

Q2. What is cluster Index?


Ans. It is used for easy retrieval of data from the database by altering the way that the
records are stored. Database sorts out rows by the column which is set to be clustered
index.

Q3. What is the use of TRUNCATE Command?


Ans. TRUNCATE command also deletes the data but delete all the rows which is
specified in the table. With full explanation https://intellipaat.com/interview-question/sql-
developer-interview-questions/

Q4. What are the types of subquery?


Ans. There are two types of subquery i.e.
1. Correlated subquery
2. Non correlated subquery

Q5. Explain primary key?


Ans. It is combination of fields which uniquely specify a row and it have no NULL value.

What is Lock Escalation?


Lock escalation is the process of reducing the overhead of the system by converting
many fine grain locks into fewer coarse grain locks. Lock escalation threshold is
determined dynamically by SQL server. It doesnt require any configuration hassles as
SQL Server choose to keep lock on both row and column for the page query.

What is RAID and what are different types of RAID levels?


RAID stands for Redundant array of independent disks which was earlier called as
Redundant array of inexpensive disks. It is a storage technology that has one logical
unit consisting of multiple disk drive components. It increases the performance by
replicating and dividing the data through many levels between multiple physical drives.
There are 12 Raid Levels which are as follows:
- Level 0: it is a 'striped' disk array (provides data stripping) without fault tolerance.
- Level 1: It is used in system for mirroring and duplexing purpose.
- Level 2: in this error correction takes place
- Level 3: it provides byte level stripping also called as bit-interleaved parity
- Level 4: is used as dedicated parity drive and it provides block level striping
- Level 5: is block interleaved distributed parity
- Level 6: is independent data disks with double parity.
- Level 0+1: is a mirror of stripes and used for replication and sharing of data among
disks
- Level 10: is a stripe of mirrors. Multiple mirrors are created and then stripes over it.
- Level 7: It adds caching to Level 3 or 4.
- Level 50: implemented as striped array with fault tolerance
- RAID S: it is proprietary striped parity RAID system
Rohit Sharma 12-7-2011
SQL Server interview questions and answers
What's the difference between a primary key and a unique key?
- Primary key is a combination of columns which uniquely specify a row whereas a
unique key is related to the superkey and can uniquely identify each row in the table.
- Primary can only be one in each table as it is one of the special cases of the unique
key whereas a unique key can be many.
- Primary key enforces the NOT NULL constraint whereas unique key doesnt. Due to
this values in the unique key columns may or may not be NULL.

What is bit data type and what's the information that can be stored inside a bit
column?
- Bit data type is the smallest type used in a language. It is used to store the boolean
information of the form 1 (true) or 0 (false). The former versions of SQL server doesnt
support NULL type in this but recent version such as SQL server 7.0 onwards it
supports NULL state as well.

Define candidate key, alternate key, and composite key.


- Candidate Key is a key which provides the uniqueness of the column(s). It identifies
each row of a table as unique. It can become the primary key of the table as well. Every
tabular relationship will have atleast one candidate key.
- Alternate Key is a type of candidate key which is formed when there are more than one
candidate key and one of them is a primary key then other keys will act as an alternate
keys. Unique keys also termed as alternate keys which prevent incorrect data from
entering the table.
- Composite Key is a special type of candidate key as it is formed by combining two or
more columns. This gives assurance of uniqueness of data when the columns are
joined together.

What are ACID properties?


ACID is used in database and it includes the following properties such as atomicity,
consistency, isolation and durability. These properties allow easy, reliable and secure
database transaction. Example: Transfer of money from one bank account to another. It
is used to manage the concurrency in the database table.

What is the difference between Locking and multi-versioning?


Locking is a means of not allowing any other transaction to take place when one is
already in progress. In this the data is locked and there wont be any modification taking
place till the transaction either gets successful or it fails. The lock has to be put up
before the processing of the data whereas
Multi-versioning is an alternate to locking to control the concurrency. It provides easy
way to view and modify the data. It allows two users to view and read the data till the
transaction is in progress.

SQL Server interview questions and answers


What's the difference between a primary key and a unique key?
- Primary key is a combination of columns which uniquely specify a row whereas a
unique key is related to the superkey and can uniquely identify each row in the table.
- Primary can only be one in each table as it is one of the special cases of the unique
key whereas a unique key can be many.
- Primary key enforces the NOT NULL constraint whereas unique key doesnt. Due to
this values in the unique key columns may or may not be NULL.

What is bit data type and what's the information that can be stored inside a bit
column?
- Bit data type is the smallest type used in a language. It is used to store the boolean
information of the form 1 (true) or 0 (false). The former versions of SQL server doesnt
support NULL type in this but recent version such as SQL server 7.0 onwards it
supports NULL state as well.

Rohit Sharma 12-7-2011


SQL Server interview questions and answers
What is normalization? Explain different forms of normalization?

Normalization is a process of organizing the data to minimize the redundancy in the


relational database management system (RDBMS). The use of normalization in
database is to decompose the relations with anomalies to produce well structured and
smaller relations. There are 6 forms of normalization which are as follows:-
- 1NF represents a relation with no repeating groups
- 2NF represents no non-prime attribute in the table
- 3NF defines that every non-prime attribute is non-transitively dependent on every
candidate key
- 4NF defines that every non-trival multi-valued dependency in table is dependent on
superkey.
- 5NF defines that every non-trival join dependency in table is implied by superkey in
table.
- 6NF defines that a table features no non-trival join dependency.

What is de-normalization and what are some of the examples of it?


De-normalization is used to optimize the readability and performance of the database by
adding redundant data. It covers the inefficiencies in the relational database software.
De-normalization logical data design tend to improve the query responses by creating
rules in the database which are called as constraints.
Examples include the following:
- Materialized views for implementation purpose such as:
- Storing the count of many objects in one-to-many relationship
- Linking attribute of one relation with other relations
- To improve the performance and scalability of web applications
SQL Server interview questions
What are the different index configurations a table can have?

No indexes
A clustered index
A clustered index and many nonclustered indexes
A nonclustered index
Many nonclustered indexes

What is BCP?

It is used to copy huge amount of data from tables and views.


It does not copy the structures same as source to destination.

What is an index?

- Indexes of SQL Server are similar to the indexes in books. They help SQL Server
retrieve the data quicker. Indexes are of two types. Clustered indexes and non-clustered
indexes. Rows in the table are stored in the order of the clustered index key.
- There can be only one clustered index per table.
- Non-clustered indexes have their own storage separate from the table data storage.
- Non-clustered indexes are stored as B-tree structures.
- Leaf level nodes having the index key and it's row locater

What is an index?

Indexes help us to find data faster. It can be created on a single column or a


combination of columns. A table index helps to arrange the values of one or more
columns in a specific order.
Disadvantages of the Indexes.

- Every time data changes in the table, all the indexes need to be updated.

- Indexes need disk space. The more indexes you have, more disk space is used.

- Index decreases the performance on inserts, updates and deletes.

- It slows down the query performance.

Define Clustered and Non-Clustered Index.

Clustered index exists as sorted row on disk.


Clustered index re-orders the table record.
Clustered index contains record in the leaf level of the B-tree.
There can be only one Clustered index possible in a table.

Non-clustered is the index in which logical order doesnt match with physical order of
stored data on disk.
Non-clustered index contains index key to the table records in the leaf level.
There can be one or more Non-clustered indexes in a table.

Explain the difference between clustered and non-clustered


index.

A clustered index reorders the way records are stored. A non clustered index is in which
the logical order of the index does not match the physical stored order of the rows on
disk. A clustered index is must faster because the index entries are actually data
records. There can be just one clustered index per table while there can be up to 249
non clustered indexes

Difference between clustered and non-clustered index.


Both stored as B-tree structure. The leaf level of a clustered index is the actual data
where as leaf level of a non-clustered index is pointer to data. We can have only one
clustered index in a table but we can have many non-clustered index in a table. Physical
data in the table is sorted in the order of clustered index while not with the case of non-
clustered data.

Explain the 'Fill factor' concept in Indexes.

- The fill factor option is provided for smoothening index data storage and performance.

- The percentage of space on each leaf level page to be filled with data is determined by
the fill factor value when an index is created.

- This reserves a percentage of free space for future growth.

- This option is provided for fine tuning index data storage and performance.

- The fill factor value is a percentage from 1 to 100 and the server-wide default is 0
which means that the leaf-level pages are filled to capacity.

How do you maintain a fill factor in existing indexes?

Usually the data keeps getting added, deleted, or updated in the table due to which the
fill factor is implemented during the index creation itself. Fill factor is not maintained after
an index is created.

The changes in the future can be determined only when a new index is created on a
table that has an existing data. It is beneficial to set the fill factor then itself.

Maintaining extra space on the data pages obviates the purpose of using the fill factor.
The SQL Server would then have to split pages to maintain an amount of free space per
the fill factor, on each page.

Thus, when data is added filling up the empty space, an index can be created and the
fill factor can be re-specified distribute the data again.
What is it unwise to create wide clustered index keys?

A clustered index is a good choice for searching over a range of values. After an
indexed row is found, the remaining rows being adjacent to it can be found easily.
However, using wide keys with clustered indexes is not wise because these keys are
also used by the non-clustered indexes for look ups and are also stored in every non-
clustered index leaf entry

What is Unique Index?

- Unique index is the index that is applied to any column of a unique value.
- A unique index can also be applied to a group of columns.
- It guarantees that the index key contains no duplicate values.
- It ensures that the data integrity of the defined columns.
- It provides additional information that helps to query optimizer to produce more
efficient execution plans.

Syntax:
CREATE UNIQUE INDEX index_name
ON table_name (column_name);

What is full-text indexing?

- Full text indexes are stored in the file system and are administered through the
database.

- Only one full-text index is allowed for one table.

- They are grouped within the same database in full-text catalogs and are created,
managed and dropped using wizards or stored procedures.

- It contains up to 1024 columns.

- It is defined at the table level and only one full-text index can be defined per table.
What is fill factor and pad index?

A fill factor is a specification done during the creation of indexes so that a particular
amount of space can be left on a leaf level page to decrease the occurrence of page
splits when the data has to be accommodated in the future.

A pad index specifies index padding. When it is set to ON, then the free space
percentage per the fill factor specification is applied to the intermediate-level pages of
the index. When it is set to OFF, the fill factor is not specified and enough space is left
for a maximum size row that an index can have

Describe important index characteristics.

- It allows to think about the significant content of the collection.

- They fasten the searching of a row.

- They are sorted by the Key values.

- They are small and contain only a small number of columns of the table.

- They refer to the appropriate block of the table with a key value.

- It encourages consistency across different archive repositories.

- It provides to specifically identify a concept.

- It has potential within the rapidly emerging Linked Data Environment.

Describe the purpose of indexes.

- It allows the server to retrieve requested data, in as few I/O operations.


- It improves the performance.
- It is used to find the records quickly in the database without scanning the entire table.
- It is list of values in a table with the storage locations of rows.
Determine when an index is appropriate.

a. When there is large amount of data. For faster search mechanism indexes are
appropriate.
b. To improve performance they must be created on fields used in table joins.
c. They should be used when the queries are expected to retrieve small data sets
d. When the columns are expected to a nature of different values and not repeated
e. They may improve search performance but may slow updates.

Вам также может понравиться