Manual Testing – SQL Queries Interview
Questions and Answers –Part 1 :
1. What is the difference between “delete” , “truncate” and
“drop” commands
2.What is the syntax for writing insert queries
4.What are DDL and DML 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>
nice :)
ReplyDeletevary good info
ReplyDelete
ReplyDeletejava.sql.SQLException: [unixODBC][ODBC Firebird Driver][Firebird]Dynamic SQL Error
SQL error code = -104
Token unknown - line 2, column 54
JOIN
SELECT PAT_ID, SEX, LAB_TEST_NAME, OBSERVATION_TYPE_NAME, LAB_RESULT_VALUE
ReplyDeleteFROM LAB_RESULT JOIN LAB_TESTS USING (LAB_TEST_NAME, JOIN ENC_DIAGNOSES USING (ENC_ID)
WHERE LAB_TEST_NAME =6044 ORDER BY PAT_ID
Useful information thank you , but i have a doubt about the line
ReplyDeleteq8 "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
Good post
ReplyDeletegood questions along with the answers! I too have similar query about q.8 though...
ReplyDeletehow can the parent table get affected if we update the view?
good collection of sql questions
ReplyDeletehowever these are not all
Good Collection & better answers. Helpful for Quick Picks. :) Thank u
ReplyDeleteselect is not DML command It's DQL command (Data Query language)
ReplyDelete"select" command belongs to DML. Please find the below wiki link.
ReplyDeletehttp://en.wikipedia.org/wiki/Data_manipulation_language
Hi Gaurav Khurana, thanks for posting a question on this.
ReplyDeleteI 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.
Thanks for sharing this information keep sharing and i would like to visit the blog again.
ReplyDeleteManual Testing Training and Manual Testing Course
Thanks for sharing...Get a 100% placement opportunity with training course more details
ReplyDeleteSoftware Testing Training in Bangalore
Such a great articles in my carrier, It's wonderful commands like easiest understand words of knowledge in information's.
ReplyDeleteSoftware Testing Training in Chennai
Artificial intelligence Training in noida
ReplyDeleteArtificial 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
Data science Training Institute in Noida
ReplyDeleteWebtrackker 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
Extremely useful information which you have shared here Manual Software Testing
DeleteGraphics designing training institute in Noida
ReplyDeleteBest 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
rpa training institute in noida
ReplyDeleteBlockchain training institute in Noida
Webtrackker Technology is IT Company and also providing the
ReplyDeleteSolidwork 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
Latest News in Hindi
ReplyDeleteLatest 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
http://webtrackker.com/Salesforce-Training-Institute-in-Noida.php
ReplyDeleteBest 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
ReplyDeleteADDRESS:- 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
Very Clear Explanation. Thank you to share this
ReplyDeleteSelenium Training Institute in chennai | Selenium Testing Training in Chennai
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>
ReplyDeleteHello, I read your blog occasionally, and I own a similar one, and I was just wondering if you get a lot of spam remarks? If so how do you stop it, any plugin or anything you can advise? I get so much lately it’s driving me insane, so any assistance is very much appreciated.
ReplyDeleteAndroid Course Training in Chennai | No.1 Android Training in Chennai
Data Science Course Training in Chennai | Best Data Science Training in Chennai
Matlab Training in Chennai | Best Matlab Course Training in Chennai
AWS Training in Chennai | No.1 AWS Training in Chennai
Selenium Course Training in Chennai | Best Selenium Training in chennai
Devops Course Training in Chennai | Best Devops Training in Chennai
Thank you for sharing such great information very useful to us.
ReplyDeleteSoftware Testing Training in Delhi
Thanks for sharing such informative blog. It really helped me a lot to learn new things about software testing. Keep on sharing informative and useful stuffs. Great blog!
ReplyDeleteSoftware Testing Services
Software Testing Services in India
Software Testing Companies in India
Software Testing Services in USA
Software Testing Companies in USA
Software Testing Companies
Software Testing Services Company
QA Testing Companies in USA
Nice post...
ReplyDeleteSSAS training
SSIS training
SSRS training
tableau training
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.
ReplyDeleteGetting 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.
ReplyDeleteVisit Bharat Go Digital Academy to learn the digital marketing skills in India.
ReplyDelete