Sie sind auf Seite 1von 10

Database related interview questions

Here we see database related interview questions which are very very imp for a p
erson who attent a microsoft related interview

What is sql
SQL is a standard computer language for accessing and manipulating database syst
ems.
SQL statements are used to retrieve and update data in a database. SQL works wit
h database programs like MS Access, DB2, Informix, MS SQL Server, Oracle, Sybase
, and other database systems.
What is ado
ADO is a programming interface to access data in a database from a web site.
ADO uses SQL to query data in a database.
Can you be precise about sql and What can u do with sql
· SQL stands for Structured Query Language
· SQL allows you to access a database
· SQL is an ANSI standard computer language
· SQL can execute queries against a database
· SQL can retrieve data from a database
· SQL can insert new records in a database
· SQL can delete records from a database
· SQL can update records in a database
Do u know any commands in sql if so tell about them
· SELECT - extracts data from a database table
· UPDATE - updates data in a database table
· DELETE - deletes data from a database table
· INSERT INTO - inserts new data into a database table
Tell some thing about ddl
The Data Definition Language (DDL) part of SQL permits database tables to be cre
ated or deleted. We can also define indexes (keys), specify links between tables
, and impose constraints between database tables.
Tell some basic ddl statements
· CREATE TABLE - creates a new database table
· ALTER TABLE - alters (changes) a database table
· DROP TABLE - deletes a database table
· CREATE INDEX - creates an index (search key)
· DROP INDEX - deletes an index
What do u know about result set
The result from a SQL query is stored in a result-set
Where we use distinct statement
The DISTINCT keyword is used to return only distinct (different) values.
Tell some thing about aliases
With SQL, aliases can be used for column names and table names
Tell syntaxes for column name aliases and table name aliases
SELECT column AS column_alias FROM table
SELECT column FROM table AS table_alias
What do u know about primary key
A primary key is a column with a unique value for each row. Each primary key val
ue must be unique within the table. The purpose is to bind data together, across
tables, without repeating all of the data in every table.
Where exactly u use joins?
we can select data from two tables with the JOIN keyword
what does inner join do?
The INNER JOIN returns all rows from both tables where there is a match.
Do u know any thing about union?
The UNION command is used to select related information from two tables, much li
ke the JOIN command. However, when using the UNION command all selected columns
need to be of the same data type.
What is union all command
The UNION ALL command is equal to the UNION command, except that UNION ALL selec
ts all values.
Tell some thing about drop index
You can delete an existing index in a table with the DROP INDEX statement.
What does truncate do?
deletes only the data inside the table
what does alter table do?
The ALTER TABLE statement is used to add or drop columns in an existing table.
How do we use fuctions in sql
SELECT function(column) FROM table
Write syntax for group by
SELECT column,SUM(column) FROM table GROUP BY column
What do u know about view
In SQL, a VIEW is a virtual table based on the result-set of a SELECT statement.
A view contains rows and columns, just like a real table. The fields in a view a
re fields from one or more real tables in the database. You can add SQL function
s, WHERE, and JOIN statements to a view and present the data as if the data were
coming from a single table.
Tell me what u know about dbms
A Database Management System (DBMS) is a computer program that can access data i
n a database.
The DBMS program enables you to extract, modify, or store information in a datab
ase.
Different DBMS programs provides different functions for querying data, reportin
g data, and modifying data.
Tell me what u know about Rdbms
A Relational Database Management System (RDBMS) is a Database Management System
(DBMS) where the database is organized and accessed according to the relationshi
ps between data.
RDBMS is the basis for SQL, and for all modern database systems like Oracle, SQL
Server, IBM DB2, Sybase, MySQL, and Microsoft Access.

SQL Server Interview Questions


RDBMS Vs DBMS:
Database management system is considered as the system to store the data for eas
y retieval and the data were relatively stored as a group. Whereas, Relational d
atabase management system will include a relationship between tables (using cons
traints). The relationship will be based on their logical relations. Considering
,
There are two table "employee" which will hold employee information like, employ
ee id, employee dob, where he is working. Another table "employee details" which
may hold his personal information like blood group, identification etc..,
For these two tables, there should be a key which will form a relation ship betw
een these two tables. Its nothing but RDBMS. (Eg: SQL Server, Oracle)
SQL Server Vs MS access:
I used to see this question acess vs sql server,
MS access is a RDBMS and can be considered as client level database. It comes al
ong with Microsoft office package. The database will be formed based on filesyst
em concept, so it wont support multiuser environment. Its preferred for very sma
ll databases. It developed on Jet engine.
SQL Server is a RDBMS and works as a Server level database. It will work for a l
arge group of Users with 24/7 availability and its preferred for high end system
with huge data and huge support. Its developed on sql server engine.
Normalization:
Normalization is a very important consideration in designing the databases. Norm
alization includes various steps like,
1. First normal form
2. Second normal form
3. third normal form
4. Backus naur form
5. Extended Backus naur form
6. Fifth normal form
7. Sixth normal form
The above normal forms are used to avoid redundancy of data. To achieve these, w
e have to segregate the columns to different tables. So that, duplication should
not be there, partial dependency should be avoided etc..,
Denormalization:
As the name indicates, it's opposite to normalisation. Introducing redundancy in
to the database is referred to as denormalization. The database becomes too comp
lex and too many joins may occur to fetch the data. In that case, we used to pre
fer this denomalization concept. Narrow idea - Joining the divided or segregated
tables.
MSDE vs SQL Server :
MSDE is the downgrade version of SQL Server, the same code with initial release
of SQL Server was named as MSDE (Microsoft Desktop Enginer).
Extent Vs Page:
Pages are 8 KB size smallest unit to store the data. Inturn, 8 Pages will form t
he extent.
Delete VS Truncate:
Delete will delete row by row in the table. The syntax is,
delete from tablename
We can give where conditions for deleting the data.
Each delete will be logged in the log file.
Its a DML statement
Trucate will deallocate the reference in the pages instead of deleting the data.
Its DDL statement. The syntax is,
Truncate table tablename
We can provide truncate with tables having foreign key relationships. (Because i
t wont do any cascade delete on the table).
It wont log any information in the log file.
Delete or truncate the data at a stretch and wont do any row by row manipulation
.

SQL Server interview questions


Some more SQL Server interview questions:
What are the authentication modes available in SQL Server?
Three types of authentication available,
1. Windows authentication - SQL Server authenticates based on the login windows
user.
2. SQL Server authentication - A specific user leve authentication will be avail
able to login into SQL Server.
3. Mixed mode authentication - It's a combination of windows and SQL Server auth
entication.

What are indexes, types and uses:


Indexes are nothing but a short cuts or high level idea about the table. SQL Ser
ver will have a high level idea about the data located. Its used to retrieve the
data faster.
Two types of indexes available,
1. Clustered Indexes. - Only one index is available and it will physically sort
the table.
This will hold the data in the leaf level and if a primary key is created. It wi
ll automatically create a clustered index. Clustered index is too heavy and took
more memory.
2. Non- clustered indexes - 249 index can be created for a table.
This will hold the reference in the leaf level. Comparatively non clustered inde
x will occupy less memory.
Rebuild index Vs Reorganize index:
Its a very important question and we need to know it for freshing up our knowled
ge.
1. Rebuilding index is nothing but, scapping all the indexes and create fresh
index so that the pages will be compressed and all the datas will be formatted
(Storage wise) Where as reorganizing the index will do a high level compaction a
nd it wont delete the existing index.
2. We should not rebuild the index duing production time and it can be done d
uring system downtime where as reorganising can be done during run time.
What do you mean by acid property?
Atomicity : The value should be atomic.
Consistency : The data in the database should be consistent. It indicates, if we
are maintaining data in two different places. Those data should resemble. If it
differs, then it will create confusions. Am I right?
Isolation : Transaction should be isolated and it should not affect the other tr
ansactions. If the transactions occured on the same data. Appropriate locks shou
ld be posted before starting the transactions.
Durability: The data should be stable.
SQL server interview questions
Let see some basic T-SQL. On reading this article, you can straight forward atte
nd an interview or you can take a SQL Server task.
CREATE TABLE EMPLOYEE(EmpID INT PRIMARY KEY , EmpFirstName VARCHAR(100),EmpLastN
ame VARCHAR(100), City VARCHAR(10),ManagerID INT, Salary int ,Designation varcha
r(10))
CREATE TABLE EMPLOYEEDETAILS(EmpID INT , EmpQualification VARCHAR(100),EmpExtn I
NT)
1. Adding Constraint between two tables, to update a foreign key relation ship.
You need to alter the child table.
ALTER TABLE EMPLOYEEDETAILS
ADD CONSTRAINT emp_for FOREIGN KEY (EmpID)
REFERENCES EMPLOYEE(EmpID)
2. Trying to insert into the child table.
INSERT INTO EMPLOYEEDETAILS VALUES(1,'BE',200)
You will get an error "The INSERT statement conflicted with the FOREIGN KEY cons
traint"
Its because, you need to populate data in the master table and corresponding col
umn should be populated in the child table.
3. Trying to insert into the master table.
INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary,Designation) VA
LUES(1,'Venkat','Prabu','Dharmapuri',1000,'PM')
Output:
(1 row(s) affected)
INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary) VALUES(1,'Venk
at','Prabu','Dharmapuri',1000)
On executing the above statement, we will get
Violation of PRIMARY KEY constraint 'PK__EMPLOYEE__3C69FB99'. Cannot insert dupl
icate key in object 'dbo.EMPLOYEE'.
Its because we are trying to insert duplicate key into the primary key column.
Let make a try with other insert statements,
INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary,ManagerID,Desig
nation) VALUES(2,'Arun','Prabu','Dharmapuri',500,1,'Dev')
INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary,Designation) VA
LUES(3,'Karthi','Prabu','Salem',2000,'Lead')
INSERT INTO EMPLOYEE(EmpID, EmpFirstName,EmpLastName,City,Salary,ManagerID,Desig
nation) VALUES(4,'Lakshmi','Prabu','Chennai',100,3,'Dev')
select * from Employee
Lets make a try to insert a row in the child table.
INSERT INTO EMPLOYEEDETAILS VALUES(1,'BE',200)
INSERT INTO EMPLOYEEDETAILS VALUES(2,'MBA',100)
INSERT INTO EMPLOYEEDETAILS VALUES(3,'BA',10)
INSERT INTO EMPLOYEEDETAILS VALUES(4,'BE',50)
INSERT INTO EMPLOYEEDETAILS VALUES(4,'BE',500)
--delete from Employeedetails where EmpID=1
select * from Employeedetails
4. Employee earning maxiumum salary
select max(salary) from EMPLOYEE
I need the max salary on each designation
select max(salary),designation from Employee Group by designation
I need max salary based on employee city
select max(salary),city from Employee Group by city
I need to check the max salary of the employees who is having salary >=1000 base
d on city.
select max(salary),city from Employee where Salary >=1000
Group by city
Total salary given to employees by the company
select sum(salary) from Employee
Total salary given to employees grouped by designation
select sum(salary),designation from Employee Group by designation
Total employees available in the company
select count(*) from employee
5. Employee Search
I need an employee with First name as "Venkat"
select EmpID,EmpFirstName from employee where EmpFirstName='Venkat'
I need an employee with Firstname start with "V"
select EmpID,EmpFirstName from employee where EmpFirstName like 'V%'

I need an employee with Firstname having second letter as "e"


select EmpID,EmpFirstName from employee where EmpFirstName like '_e%'
I need an employee with firstname ended with the letter "t"
select EmpID,EmpFirstName from employee where EmpFirstName like '%t'
I need an employee whose city is "Chennai"
select EmpID,EmpFirstName from employee where city ='Chennai'
6. List down the employees having more than one extension number
select empid from employeedetails group by empid having count( EmpExtn)>1
Happy Learning!!
Regards,
Venkatesan Prabu .J
Posted by Venkatesan Prabu at 11:26 PM 2 comments Links to this post
Labels: SQL Server Interview questions
SQL Server Interview Questions
RDBMS Vs DBMS:
Database management system is considered as the system to store the data for eas
y retieval and the data were relatively stored as a group. Whereas, Relational d
atabase management system will include a relationship between tables (using cons
traints). The relationship will be based on their logical relations. Considering
,
There are two table "employee" which will hold employee information like, employ
ee id, employee dob, where he is working. Another table "employee details" which
may hold his personal information like blood group, identification etc..,
For these two tables, there should be a key which will form a relation ship betw
een these two tables. Its nothing but RDBMS. (Eg: SQL Server, Oracle)
SQL Server Vs MS access:
I used to see this question acess vs sql server,
MS access is a RDBMS and can be considered as client level database. It comes al
ong with Microsoft office package. The database will be formed based on filesyst
em concept, so it wont support multiuser environment. Its preferred for very sma
ll databases. It developed on Jet engine.
SQL Server is a RDBMS and works as a Server level database. It will work for a l
arge group of Users with 24/7 availability and its preferred for high end system
with huge data and huge support. Its developed on sql server engine.
Normalization:
Normalization is a very important consideration in designing the databases. Norm
alization includes various steps like,
1. First normal form
2. Second normal form
3. third normal form
4. Backus naur form
5. Extended Backus naur form
6. Fifth normal form
7. Sixth normal form
The above normal forms are used to avoid redundancy of data. To achieve these, w
e have to segregate the columns to different tables. So that, duplication should
not be there, partial dependency should be avoided etc..,
Denormalization:
As the name indicates, it's opposite to normalisation. Introducing redundancy in
to the database is referred to as denormalization. The database becomes too comp
lex and too many joins may occur to fetch the data. In that case, we used to pre
fer this denomalization concept. Narrow idea - Joining the divided or segregated
tables.
MSDE vs SQL Server :
MSDE is the downgrade version of SQL Server, the same code with initial release
of SQL Server was named as MSDE (Microsoft Desktop Enginer).
Extent Vs Page:
Pages are 8 KB size smallest unit to store the data. Inturn, 8 Pages will form t
he extent.
Delete VS Truncate:
Delete will delete row by row in the table. The syntax is,
delete from tablename
We can give where conditions for deleting the data.
Each delete will be logged in the log file.
Its a DML statement
Trucate will deallocate the reference in the pages instead of deleting the data.
Its DDL statement. The syntax is,
Truncate table tablename
We can provide truncate with tables having foreign key relationships. (Because i
t wont do any cascade delete on the table).
It wont log any information in the log file.
Delete or truncate the data at a stretch and wont do any row by row manipulation
.
More SQL server Interview questions at,
http://venkattechnicalblog.blogspot.com/2008/09/sql-server-interview-questions_1
1.html
http://venkattechnicalblog.blogspot.com/2008/09/sql-server-interview-question-pa
rt-2.html
http://venkattechnicalblog.blogspot.com/2008/09/sql-server-interview-questions.h
tml
Happy Learning!!!
Regards,
Venkatesan Prabu .J
Posted by Venkatesan Prabu at 1:31 AM 6 comments Links to this post
Labels: SQL Server Interview questions
11.9.08
SQL Server interview questions
Some more SQL Server interview questions:
What are the authentication modes available in SQL Server?
Three types of authentication available,
1. Windows authentication - SQL Server authenticates based on the login windows
user.
2. SQL Server authentication - A specific user leve authentication will be avail
able to login into SQL Server.
3. Mixed mode authentication - It's a combination of windows and SQL Server auth
entication.

What are indexes, types and uses:


Indexes are nothing but a short cuts or high level idea about the table. SQL Ser
ver will have a high level idea about the data located. Its used to retrieve the
data faster.
Two types of indexes available,
1. Clustered Indexes. - Only one index is available and it will physically sort
the table.
This will hold the data in the leaf level and if a primary key is created. It wi
ll automatically create a clustered index. Clustered index is too heavy and took
more memory.
2. Non- clustered indexes - 249 index can be created for a table.
This will hold the reference in the leaf level. Comparatively non clustered inde
x will occupy less memory.
Rebuild index Vs Reorganize index:
Its a very important question and we need to know it for freshing up our knowled
ge.
1. Rebuilding index is nothing but, scapping all the indexes and create fresh
index so that the pages will be compressed and all the datas will be formatted
(Storage wise) Where as reorganizing the index will do a high level compaction a
nd it wont delete the existing index.
2. We should not rebuild the index duing production time and it can be done d
uring system downtime where as reorganising can be done during run time.
What do you mean by acid property?
Atomicity : The value should be atomic.
Consistency : The data in the database should be consistent. It indicates, if we
are maintaining data in two different places. Those data should resemble. If it
differs, then it will create confusions. Am I right?
Isolation : Transaction should be isolated and it should not affect the other tr
ansactions. If the transactions occured on the same data. Appropriate locks shou
ld be posted before starting the transactions.
Durability: The data should be stable.
Regards,
Venkatesan Prabu .J
Posted by Venkatesan Prabu at 3:50 AM 0 comments Links to this post
Labels: SQL Server Interview questions
5.9.08
SQL Server Interview questions
What is the significance of NULL value and why should we avoid permitting null v
alues?
Null means no entry has been made. It implies that the value is either unknown o
r undefined.
We should avoid permitting null values because
Column with NULL values can't have PRIMARY KEY constraints. Certain calculations
can be inaccurate if NULL columns are involved.
What is SQL whats its uses and its component ?
The Structured Query Language (SQL) is foundation for all relational database sy
stems. Most of the large-scale databases use the SQL to define all user and admi
nistrator interactions. It enable us to retrieve the data from based on our exac
t requirement. We will be given a flexibility to store the data in our own forma
t.
The DML component of SQL comprises four basic statements:
* SELECT to get rows from tables
* UPDATE to update the rows of tables
* DELETE to remove rows from tables
* INSERT to add new rows to tables
What is DTS in SQL Server ?
Data Transformation Services is used to transfer the data from one source to our
required destination. Considering am having some data in sql server and I need
to transfer the data to Excel destination. Its highly possible with dialogue bas
ed tool called Data Transformation services. More customization can be achieved
using SSIS. A specialized tool used to do such migration works.
What is the difference between SQL and Pl/Sql ?
Straight forward. SQL is a single statement to finish up our work.
Considering, I need some data from a particular table.
Select * from table will fetch the necessary information. Where as I need to do so
me row by row processing. In that case, we need to go for Programming Logic / SQ
L.
What is the significance of NULL value and why should we avoid permitting null v
alues?
Null means no entry has been made. It implies that the value is either unknown o
r undefined.
We should avoid permitting null values because
Column with NULL values can't have PRIMARY KEY constraints. Certain calculations
can be inaccurate if NULL columns are involved.
Difference between primary key and Unique key?
Both constraints will share a common property called uniqueness. The data in the
column should be unique. The basic difference is,
· Primary key won t allow null value. Whereas, unique key will accept null value but
only one null value.
· On creating primary key, it will automatically format the data inturn creates cl
ustered index on the table. Whereas, this characteristics is not associated with
unique key.
· Only one primary key can be created for the table. Any number of Unique key can
be created for the table.

Das könnte Ihnen auch gefallen