Single Post

Header

Saturday, August 1, 2015

Manual Testing – SQL Queries Interview Questions and Answers –Part 1 :


Manual Testing – SQL Queries Interview Questions and Answers –Part 1 :

1. What is the difference between “delete” , “truncate” and “drop” commands

Delete Command Truncate Command Drop Command
Delete Command Belongs to DML Truncate Command Belongs to DDL Drop Command Belongs to DDL
Can be Used to delete entire Table data Can be Used to delete entire Table data Can be Used to delete entire Table data and also the structure
Can be used to delete specific rows using where clause Can't be used to delete specific rows using where clause Can't be used to delete specific rows using where clause
Can be rolled back Can't be rolled back Can't be rolled back

2.What is the syntax for writing insert queries
We can write insert queries in two ways :
a.insert into <table-name> values (value1,value2,…..)
b.insert into <table-name> (col1,col2,……) values (value1,value2,…..)

3.What is the difference between primary key and unique key

Unique Key Primary Key
a.A table can contain more than one unique key a.A table can contain only one primary key (can be one/more columns)
b.Unique key allows one null value b.Primary key will not allow null values

4.What are DDL and DML commands .

DDL (DataDifinition Language) DML (Data Manipulation Language)
Create Select
Alter Insert
Truncate Update
Drop Deletet

5. What is the difference between sub queries and joins
a.Sub Queries :
To write sub queries between two or more tables, there is no need to be relation exist among those tables
b.Joins:
To write joins between two or more tables, there should be relation exist among those tables

6. What are the different  types of joins and explain them
Inner Join
Left Outer Join
Right Outer Join
Full Outer Join

7. Write  syntax for views and stored procedures
View Syntax:
Create view <view-name> as select <column names> from <table-name> where <condition>
Stored Procedure Sysntax:
Create procedure <procedure-name> as begin select <column names> from <table-name> end

Note: These are only sample examples, we can write in different ways also.

8. Relation between views and the their parent tables
If we modify the views table,it effects the parent tables and vice versa

9. Write syntax for update query
Update <table-name> set some_co1l=value1, some_col2=value2 where some_col3=value3

10.What are the different constraints available in sql and Explain
Not Null      -> enforces a column to Not accept Null values
Unique       -> uniquely identifies each record in a database table
Primary Key -> uniquely identifies each record in a database table and it cannot contain NULL values.
Foreign Key -> A Foreign Key in one table points to a PRIMARY KEY in another table.
Check         -> It is used to limit the value range that can be placed in a column.
Default       -> It is used to insert a default value into a column.

11.By default how the column data would display if use order by <column>
By default the order by would display the data in ascending order
Syntax:
a. select <col-names> from <table-name> order by <col-names>
It will display the results in ascending order
select <col-names> from <table-name> order by <col-names> desc
It will display the results in descending order
select <col-names> from <table-name> order by <col-names> asc
It will display the results in ascending order

12.What is the operator in sql to find pattern match
Like
Select <colnames> from <table-name> where <col> like <pattern>
Ex:
a.
Select ename from emp where ename like ‘v%’
It will display all the names which are start with ‘v’
b.
Select ename from emp where ename not like ‘v%’
It will display other than all the names which are start with ‘v’


13. What is the purpose of ‘distinct’ in sql
Distinct is used to display only the different values

Ex:
Select distinct <col-names> from <table-name>
Select distinct ename from emp

14. What is the difference between union and union all
The UNION operator selects only distinct values by default. To allow duplicate values, use UNION ALL
Select <col-names> from <table1> union select <col-names> from <table2>
Select <col-names> from <table1> union all select <col-names> from <table2>

33 comments:


  1. java.sql.SQLException: [unixODBC][ODBC Firebird Driver][Firebird]Dynamic SQL Error
    SQL error code = -104
    Token unknown - line 2, column 54
    JOIN

    ReplyDelete
  2. SELECT PAT_ID, SEX, LAB_TEST_NAME, OBSERVATION_TYPE_NAME, LAB_RESULT_VALUE
    FROM LAB_RESULT JOIN LAB_TESTS USING (LAB_TEST_NAME, JOIN ENC_DIAGNOSES USING (ENC_ID)
    WHERE LAB_TEST_NAME =6044 ORDER BY PAT_ID

    ReplyDelete
  3. Useful information thank you , but i have a doubt about the line
    q8 "If we modify the views table,it effects the parent tables and vice versa"
    can you explain this, how can modifying views will affect parent tables,, view takes data from tables so if we change view how tables can get affected

    regards
    gaurav K
    www.udzial.blogspot.in

    ReplyDelete
  4. good questions along with the answers! I too have similar query about q.8 though...
    how can the parent table get affected if we update the view?

    ReplyDelete
  5. good collection of sql questions
    however these are not all

    ReplyDelete
  6. Good Collection & better answers. Helpful for Quick Picks. :) Thank u

    ReplyDelete
  7. select is not DML command It's DQL command (Data Query language)

    ReplyDelete
  8. "select" command belongs to DML. Please find the below wiki link.
    http://en.wikipedia.org/wiki/Data_manipulation_language

    ReplyDelete
  9. Hi Gaurav Khurana, thanks for posting a question on this.
    I am giving the below examples to clarify your question

    1.Create a view CUSTOMERS_VIEW from

    CREATE VIEW CUSTOMERS_VIEW AS
    SELECT name, age
    FROM CUSTOMERS;

    2.Update any row(s) on view table.

    UPDATE CUSTOMERS_VIEW
    SET AGE = 35
    WHERE name='Ramesh';

    This would ultimately update the base table CUSTOMERS and same would reflect in the view itself.

    3.Delete any row(s) from view
    DELETE FROM CUSTOMERS_VIEW
    WHERE age = 22;
    This would ultimately delete a row from the base table CUSTOMERS and same would reflect in the view itself.

    Hope you understand better now.

    ReplyDelete
  10. Thanks for sharing this information keep sharing and i would like to visit the blog again.
    Manual Testing Training and Manual Testing Course

    ReplyDelete
  11. Thanks for sharing...Get a 100% placement opportunity with training course more details
    Software Testing Training in Bangalore

    ReplyDelete
  12. Such a great articles in my carrier, It's wonderful commands like easiest understand words of knowledge in information's.
    Software Testing Training in Chennai

    ReplyDelete
  13. Artificial intelligence Training in noida
    Artificial intelligence Training in noida-Artificial Intelligence Training in Noida, Artificial Intelligence Training classes in Noida, Artificial Intelligence Training classes in Noida, Artificial Intelligence Training

    by Real time ARTIFICIAL INTELLIGENCE Experts, Big-Data and ARTIFICIAL INTELLIGENCE Certification Training in Noida



    WEBTRACKKER TECHNOLOGY (P) LTD.
    C - 67, sector- 63, Noida, India.
    F -1 Sector 3 (Near Sector 16 metro station) Noida, India.

    +91 - 8802820025
    0120-433-0760
    0120-4204716
    EMAIL: info@webtrackker.com
    Website: www.webtrackker.com



    Our Other Courses:


    artificial intelligence Training in noida

    SAS Training Institute in Delhi

    SAS Training in Delhi

    SAS Training center in Delhi

    Sap Training Institute in delhi

    Sap Training in delhi

    Best Sap Training center in delhi

    Best Software Testing Training Institute in delhi

    Software Testing Training in delhi

    Software Testing Training center in delhi

    Best Salesforce Training Institute in delhi

    Salesforce Training in delhi

    Salesforce Training center in delhi

    Best Python Training Institute in delhi



    Python Training in delhi


    Best Android Training Institute In delhi


    Best Python Training center in delhi


    Android Training In delhi


    best Android Training center In delhi

    ReplyDelete
  14. Data science Training Institute in Noida

    Webtrackker Data science Training Institute in Noida Accelerate your career in data science by starting from basics in Statistics, Data Management and Analytics to advanced topics like Neural Networks, Machine Learning and Big Data.



    http://webtrackker.com/Best-Data-Science-Training-Institute-in-Noida.php



    Data science Training Institute in Noida

    OUR OTHER COURCES

    SAS Training center in Delhi


    Best Software Testing Training Institute in delhi

    Best Salesforce Training Institute in delhi

    Best Python Training Institute in delhi



    ReplyDelete
  15. Graphics designing training institute in Noida
    Best Graphics training institute in Noida, Graphic Designing Course, classes in Noida- webtrackker is providing the graphics training in Noida with 100% placement supports. If you are looking for the Best Graphics designing training institute in Noida For more call - 8802820025.

    Graphics designing training institute in Noida, Graphics designing training in Noida, Graphics designing course in Noida, Graphics designing training center in Noida

    Company address:
    Webtrackker Technology
    C- 67, Sector- 63, Noida
    Phone: 01204330760, 8802820025
    Email: info@webtrackker.com
    Website: http://webtrackker.com/Best-institute-for-Graphic-Designing-training-course-in-noida.php

    ReplyDelete
  16. Webtrackker Technology is IT Company and also providing the
    Solidwork training in Noida at running project by the real
    time working trainers. If you are looking for the Best Solidwork
    training institute in Noida then you can contact to webtrackker technology.
    ads
    Webtrackker Technology
    C- 67, Sector- 63 (Noida)
    Phone: 0120-4330760, 8802820025

    8802820025
    Solidwork training institute in Noida

    ReplyDelete
  17. Latest News in Hindi

    Latest News in Hindi- Hindustan channel is the best online web portal in india where you read the all latest indian news in hindi. if you are looking the Latest News in Hindi, live news channel, hindi news channel, live news channels in hindi, live hindi channels then hindustan channel is best for you.
    Latest News in Hindi
    Company address:
    C- 67, Sector- 63, Noida
    Phone: 01204330760, 8802820025


    URL: https://hindustanchannel.com

    ReplyDelete
  18. http://webtrackker.com/Salesforce-Training-Institute-in-Noida.php

    ReplyDelete
  19. Best Salesforce training institute in Noid-, Best Salesforce developer training in Noida, Best Salesforce developer training institute in Noida, Best Salesforce developer training in Noida, Salesforce developer training and course content, Salesforce developer courses & certification training programs, Best Salesforce developer training In Noida, best Salesforce developer training institute in Noida, top ten Salesforce developer training institute in Noida, Top Ten Salesforce developer training institute in Noida, Best Salesforce developer training institute in Noida

    ADDRESS:- C-67 SECTOR 63
    FIRST FLOOR
    NOIDA NEAR SECTOR 63 POLICE CHOWKI ;
    Branch= E - 47 sector 3

    , Near sector 16 motro station
    First floor
    near metro station sec -16


    behind of hcl back gate




    Salesforce Training Institute in Noida


    ReplyDelete
  20. Thanks For sharing the Information The Information Shared Is Very valuable please Keep Updating Us The InFormation Shared Is Very Valuable Python Online Training Hadoop Online Training <a href="https://nareshit.com/data-science-online-training/>DataScience Online Training</a>

    ReplyDelete
  21. Thank you for sharing such great information very useful to us.
    Software Testing Training in Delhi

    ReplyDelete
  22. Nice Blog, When i was read this blog i learnt new things & it’s truly have well stuff related to developing technology, Thank you for sharing this blog. Need to learn software testing company,visit here.

    ReplyDelete
  23. Getting into Integrated Marketing is tough if you don’t have thorough knowledge. Then why not join Talentedge, the first ed-tech platform that has joined hands with XLRI and MICA to provide the best courses to the students.

    ReplyDelete
  24. Visit Bharat Go Digital Academy to learn the digital marketing skills in India.

    ReplyDelete