SQL Server Interview Questions

Ques. What are the different type of SQL's statements ?

Ans. 1. DDL – Data Definition Language DDL is used to define the structure that holds the data. For example, Create, Alter, Drop and Truncate table. 2. DML– Data Manipulation Language DML is used for manipulation of the data itself. Typical operations are Insert, Delete, Update and retrieving the data from the table. Select statement is considered as a limited version of DML, since it can't change data in the database. But it can perform operations on data retrieved from DBMS, before the results are returned to the calling function. 3. DCL– Data Control Language DCL is used to control the visibility of data like granting database access and set privileges to create tables etc. Example - Grant, Revoke access permission to the user to access data in database.

Ques. What are the Advantages of SQL?

Ans. 1. SQL is not a proprietary language used by specific database vendors. Almost every major DBMS supports SQL, so learning this one language will enable programmers to interact with any database like ORACLE, SQL ,MYSQL etc. 2. SQL is easy to learn. The statements are all made up of descriptive English words, and there aren't that many of them. 3. SQL is actually a very powerful language and by using its language elements you can perform very complex and sophisticated database operations.

Ques. what is a field in a database ?

Ans. A field is an area within a record reserved for a specific piece of data. Examples: Employee Name, Employee ID etc

Ques. What is a primary key?

Ans. A primary key is a column whose values uniquely identify every row in a table. Primary key values can never be reused. If a row is deleted from the table, its primary key may not be assigned to any new rows in the future. To define a field as primary key, following conditions had to be met : 1. No two rows can have the same primary key value. 2. Every row must have a primary key value 3. The primary key field cannot be null 4. Values in primary key columns can never be modified or updated

Ques. What is a Composite Key ?

Ans. A Composite primary key is a type of candidate key, which represents a set of columns whose values uniquely identify every row in a table. For example - if "Employee_ID" and "Employee Name" in a table is combined to uniquely identify a row its called a Composite Key.

Ques. What is a Composite Primary Key ?

Ans. A Composite primary key is a set of columns whose values uniquely identify every row in a table. What it means is that, a table which contains composite primary key will be indexed based on the columns specified in the primary key. This key will be referred in Foreign Key tables. For example - if the combined effect of columns, "Employee_ID" and "Employee Name" in a table is required to uniquely identify a row, its called a Composite Primary Key. In this case, both the columns will be represented as primary key.

Ques. What is a Foreign Key ?

Ans. When a "one" table's primary key field is added to a related "many" table in order to create the common field which relates the two tables, it is called a foreign key in the "many" table. For example, the salary of an employee is stored in salary table. The relation is established via foreign key column “Employee_ID_Ref” which refers “Employee_ID” field in the Employee table.

Ques. What is a Unique Key ?

Ans. Unique key is same as primary with the difference being the existence of null. Unique key field allows one value as NULL value.

Post Question