SQL Interview Question And Answer | SQL Interview Question And Answer for Fresher | SQL Server | Set-04

1.What is join?
 Ans: SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables.

2.What is Inner Join?
 Ans: Inner join is a join that selects only those records from both database tables that have matching values.
 
      Syntax:  SELECT column_name(s) FROM table_name1  INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name

3.What is Outer Join?
 Ans: Outer join selects all the records from one table and select only those records in second table that have matching values.

      Left Outer Join: Left Outer Join is a join that select all the record from left table(1st table) in database  and select matching rows from the right table(2nd table).

      Syntax: SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2 ON table_name1.column_name=table_name2.column_name

      Right Outer Join: Right Outer Join is a join that select all the records from right table in database and select matching rows from left table in database.

      Syntax: SELECT column_name(s) FROM table_name1 RIGHT JOIN table_name2  ON table_name1.column_name=table_name2.column_name

4.What is Self JOin?
 Ans: SQL self-join simply is a normal join which is used to join a table to itself.

      Syntax: SELECT column_list From table_A  AS A INNER JOIN table_A AS B ON A.column name1 == B.column_name1,… WHERE row_conditions

5.What Storeprocedure?
 Ans: Storeprocedure is a precompiled collection of SQL statement and optional control of flow statements stored under a name and processed as a unit.

  Advantage:
        1.They allow modular programming: we can create the procedure once, store it in the database and we can call it more than one times.
        2. They allow faster execution.
        3.They can reduce network traffic.
        4. Storeprocedure provides a better security to your data.
        5.We can change storeprocedure code with out affecting client.

6.What is difference between DELETE and TRUNCATE?
 Ans: 1.TRUNCATE will actually remove s all the rows from a table after we run the TRUNCAT command
        DELETE command removes rows data from a table based on the condition that we provide with  WHERE clause
        2.TRUNCATE cannot activate TRIGGER. But DELETE can activate TRIGGER.
        3.TRUNCATE can not be RollBack but DELETE can be RollBack.
        4.TRUNCATE is DDL command and DELETE is DML command.
        5.TRUNCATE reset the identity of the table but DELETE does not reset the identity of the table.
7.What is SUB-QUERY?
 Ans:Sub query are often refer to as sub select as they allow a select statement to be executed arbitrarily with in the body of another SQL statement.

8.Difference between VARCHAR and VARCHAR 2?
 Ans: 1.VARCHAR store upto 2000 bytes of character whereas VARCHAR2 store upto 4000 bytes of character.
         2.If  we declare datatype as VARCHAR then it occupy space for NULL values whereas VARCHAR 2 not occupy space for NULL value.

9.What is Clustered Index?
Ans: Clustered Indexes defines the physical shorting of a database table's rows in a storage-media.

10.What is Non Clustered Index?
  Ans: Non Clustered Index are created outside of the database table and contain a shorted list of reference to the table itself.


Previous Next


:: Click the links below for similar type Questions and answers ::

0 comments:

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes