SQL interview questions ?

 

1.       1.   What is SQL?

SQL stands for structure query language It is standard language used to maintain the relational database perform Many difficult data manipulation operations on the data. SQL was initially invented in 1970,

It is a database language used for database creation, deletion, fetching and modifying rows etc. sometimes it is pronounced as ‘sequel’. We can also use it to handle organized data comprised of entities (variables) and relations between different entities of the data.

 

 

          2. When SQL appeared?

                SQL first appeared in 1974 It is one of the most used languages for maintaining the relational database In 1986 SQL became the standard of the American National Standards Institute (ANSI) and ISO (International Organization for Standardization) in 1987

 

 

3.       3.  What is clustered Index in SQL?

     A clustered index is actually a table where the data for the rows are stored. It determines the order of the table database on the key-values that can sort in only one direction. Each table can have only one clustered index. It is the only index, which has been automatically created when the primary key is generated. It many data modifications needed to be done in the table then clustered are preferred

 

 

4.       4.   What are the usages of SQL?

      SQL is responsible for maintaining the relational data and the data structures present in the database .some of the common usage are given below

a.       To execute  queries against a database

b.      To retrieve data from   a database

c.       To insert records in a database

d.      To updates records in a database

e.      To delete records from a database

f.        To create new database

g.       To create new tables in a database

h.      To create new views in database

i.         To perform complex operation on the database

 

5.       Does SQL support programming language features?

       SQL refers to the standard query language .Therefore it is true that SQL is a language but does not actually support the programming language. It is common language that doesn’t have a loops, conditional statements and logical operations. It cannot be used for anything other than data manipulation. The primary purpose of the SQL is to maintain, retrieve, manipulate, update, delete and perform complex operations like joins on the data present in the database.

 

 

6.      6. What is the purpose of DDL Language?

DDL stands for Data definition language .It is the  subset of a databases that defines the data structure of the database when the database is created for Example:- we can use the DDL command to add, remove or modify tables It consists of the following commands CREATE, ALTER and DELETE  database objects such as schema tables, indexes ,view, sequence, etc

.

      7 What are the subsets of the SQL?

              The following are the four significant subsets of the SQL

a.       Data definition language (DDL):-

           It defines the data structure that consists of the commands like CREATE, ALTER, DROP, etc

b.      Data manipulation language(DML):-

            It is used to manipulate existing data in the database .The commands in this category are SELECT, UPDATE, INSERT, etc

c.       Data control language :-

       It controls access to the data stored in the database .The commands in this category include GRANT and REVOKE

d.      Transaction control language(TCL):-

            It is used to deal with the transaction operations in the database. The commands in this category are COMMIT, ROLLBACK, SET TRANSACTION, SAVEPOINT, etc

 

8.      8. What is primary key?

     A primary key is a field or the combination of fields that uniquely identifying each record in the table. It is one the special kind of unique key. If the columns contains a primary key it cannot be null or empty .A table can have more than one primary key. It always stores unique values into a row

 

 

9.      9. What do you mean by table a field in SQL?

    A table refers to a collection of data in an organised manner in form of rows and columns . A field refers to the number of columns in a table.

  Example:-   Table- StudentInformation

                       Field-StuId, StuName, StuMarks etc

 

10.   What are constraints?

       Constraints in SQL are used to specify the limit on the data type of the table. I can be specified while creating an altering the table statements. The sample of the constraints are-

  a. NOT NULL

b. CHECK

c. DEFAULT

d. UNIQUE

e. PRIMARY KEY

f. FOREIGN KEY

 

 

       11. Explain different types of Normalization?

          There are many successive levels of normalizations. These are called normal forms each consecutive normal form depends on the previous one. The first three normal forms are usually adequate.

a.       First normal form(INF)-

         No repeating groups within rows

b.      Second normal form(SNF)-

        Every non-key (supporting) column value is dependent on the whole primary key.

c.       Third  normal form(TNF)-

         Dependent solely on the primary key an no other non-key (supporting) column value.

 

 

12    What do you mean by “Trigger “ in SQL?

          Trigger in SQL is are a special type of stored procedures that are defined to execute automatically in  place or after data modification . It allows you to execute a batch of the code where an insert, update or any other query is executing against a specific table.

 

 

13.  What is difference between cross join and natural join?

    The cross joins produces the cross product or Cartesian product of two tables whereas the natural join is based on all the columns having the same name and data types in both the tables.

 

14. What is the need for group function in SQL?

     Group function work on the set of rows and return on the result per group.  Some of the commonly used group functions are – AVG, COUNT, MAX, MIN, SUM, VERIANCE

 

15. How can you fetch records from two tables?

         You can fetch common records from two tables using INTERSECT.

 

16. What are the different set operators available in SQL?

    Some of the available set operators are UNION, INTERSECT, or MINUS operator.

 

 

17. What is stored procedure?

     A stored procedure is a function which consists of many SQL statements to access he database system Several SQL statements are consolidated into a stored procedure and execute them whenever and wherever required which saves time and avoid writing code again and again

 

18. What is UNIQUE key?

       Uniquely identifies a single row in the table. Multiple values per table in table .NULL values allowed.

 

19.  What is the difference between CHAR and VARCHAR data type in SQL?

      Both CHAR and VARCHAR are used for characters data type but VARCHAR is used for character string of variable length whereas CHAR is used for strings of fixed length.

Example:- CHAR(10) can only store 10 characters and will not be able to store a string of any other length whereas VARCHAR(10) can store any length i.e. 6,8,2 in this variable

 

20. What is the difference between SQL and MYSQL?

SQL

MYSQL

SQL is  Standard language  which stands for structured query language based on the English language

MYSQL is a database management system

SQL is the core of the relational database which is used for accessing and managing database

MYSQL is an RDBMS(Relational database management system) such as SQL server, Informix etc.

 

21. What is relationship and what are they?

     Relation or links are between entities that have something to do with each other .Relationships are defined as the connection between the tables in a database .There are various relationships namely:

a.       One to one relationship

b.      One to many relationship

c.       Many to one relationships

d.      Self referencing relationship

 

22. Explain different type’s index in SQL?

        There are three types of index in SQL namely:-

a.       UNIQUE Index-

        This index does not allow the field to have duplicate if the column is unique indexed. It is a primary key is defined a unique index can be applied automatically

b.      Clustered index :-

         This index records the physical order of the table and searches based on the basis of key values .Each table can only have one clustered index.

c.       Non-clustered index:-

      Non-clustered index does not alter the physical order of the table and maintains a logical order of the data. Each table can have many non-clustered indexes

 

 

 

 

 

         

Comments

Blogs