You are on page 1of 14

Q#1. What does SQL stand for?

Ans. SQL stands for Structured Query Language.

Q#2. How to select all records from the table?


Ans. To select all the records from the table we need to use following syntax:

Select * from table_name;

Q#3. Define join and name different type of joins?


Ans. Join keyword is used to fetch data from related two or more tables. It returns rows where
there is at least one match in both the tables included in join. Read more here.
Type of joins are-

1. Right Join
2. Outer Join
3. Full Join
4. Cross Join
5. Self Join.

Q#4. What is the syntax to add record to a table?


Ans. To add record in a table INSERT syntax is used.

Ex: INSERT into table_name VALUES (value1, value2..);

Q#5. How do you add a column to a table?


Ans. To add another column in the table following command has been used.

ALTER TABLE table_name ADD (column_name);

Q#6. Define SQL Delete statement.


Ans. Delete is used to delete a row or rows from a table based on the specified condition.
Basic syntax is as follows:

DELETE FROM table_name

WHERE <Condition>

Q#7. Define COMMIT ?


Ans. COMMIT saves all changes made by DML statements.

Q#8. What is a primary key?


Ans. A Primary key is column whose values uniquely identify every row in a table. Primary key
values can never be reused.
Q#9. What are foreign keys?
Ans. When a one table’s primary key field is added to related tables in order to create the
common field which relates the two tables, it called a foreign key in other tables.
Foreign Key constraints enforce referential integrity.

Q#10. What is CHECK Constraint?


Ans. A CHECK constraint is used to limit the values or type of data that can be stored in a
column. They are used to enforce domain integrity.

Q#11. Is it possible for a table to have more than one foreign key?
Ans. Yes, a table can have many foreign keys and only one primary key.

Q#12. What are the possible values for BOOLEAN data field.
Ans. For a BOOLEAN data field two values are possible: -1(true) and 0(false).

Q#13. What is a stored procedure?


Ans. A stored procedure is a set of SQL queries which can take input and send back output.

Q#14. What is identity in SQL?


Ans. An identity column in the SQL automatically generates numeric values. We can defined a
start and increment value of identity column.

Q#15. What is Normalization?


Ans. The process of table design to minimize the data redundancy is called normalization. We
need to divide a database into two or more table and define relationships between them.

Q#16. What is Trigger?


Ans. Trigger allows us to execute a batch of SQL code when a table event occurs (Insert, update
or delete command executed against a specific table)

Q#17. How to select random rows from a table?


Ans. Using SAMPLE clause we can select random rows.

Example:
SELECT * FROM table_name SAMPLE(10);

Q#18. Which TCP/IP port does SQL Server run?


Ans. By default SQL Server runs on port 1433.

Q#19. Write a SQL SELECT query that only returns each name only once
from a table?
Ans. To get the each name only once, we need to use the DISTINCT keyword.

SELECT DISTINCT name FROM table_name;


Q#20. Explain DML and DDL?
Ans. DML stands for Data Manipulation Language. INSERT, UPDATE and DELETE are DML
statements.

DDL stands for Data Definition Language. CREATE ,ALTER, DROP, RENAME are DDL
statements.

Q#21. Can we rename a column in the output of SQL query?


Ans. Yes using the following syntax we can do this.

SELECT column_name AS new_name FROM table_name;

Q#22. Give the order of SQL SELECT ?


Ans. Order of SQL SELECT clauses is: SELECT, FROM, WHERE, GROUP BY, HAVING,
ORDER BY. Only the SELECT and FROM clause are mandatory.

Q#23. Suppose a Student column has two columns, Name and Marks. How to
get name and marks of top three students.
Ans. SELECT Name, Marks FROM Student s1 where 3 <= (SELECT COUNT(*) FROM
Students s2 WHERE s1.marks = s2.marks)

Q#24. What is SQL comments?


Ans. SQL comments can be put by two consecutive hyphens (–).

Q#26. What are the properties of a transaction?


Ans. Generally these properties are referred as ACID properties. They are:

1. Atomicity
2. Consistency
3. Isolation
4. Durability.

Q#27. What do you mean by ROWID ?


Ans. It’s a 18 character long pseudo column attached with each row of a table.

Q#28. Define UNION, MINUS, UNION ALL, INTERSECT ?


Ans. MINUS – returns all distinct rows selected by the first query but not by the second.

UNION – returns all distinct rows selected by either query

UNION ALL – returns all rows selected by either query, including all duplicates.

INTERSECT – returns all distinct rows selected by both queries.


Q#29. What is a transaction?
Ans. A transaction is a sequence of code that runs against a database. It takes database from one
consistent state to another.

Q#30. What is difference between UNIQUE and PRIMARY KEY


constraints?
Ans. A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE
keys.

Primary key cannot contain Null values whereas Unique key can contain Null values.

Q#31. What is a composite primary key?


Ans. Primary key created on more than one column is called composite primary key.

Q#32. What is an Index ?


Ans. An Index is an special structure associated with a table speed up the performance of
queries. Index can be created on one or more columns of a table.

Q#33. What is the Subquery ?


Ans. A Subquery is sub set of select statements whose return values are used in filtering
conditions of the main query.

Q#34. What do you mean by query optimization?


Ans. Query optimization is a process in which database system compares different query
strategies and select the query with the least cost.

Q#36. What is Referential Integrity?


Ans. Set of rules that restrict the values of one or more columns of the tables based on the values
of primary key or unique key of the referenced table.

Q#37. What is Case Function?


Ans. Case facilitates if-then-else type of logic in SQL. It evaluates a list of conditions and returns
one of multiple possible result expressions.

Q#38. Define a temp table?


Ans. A temp table is a temporary storage structure to store the data temporarily.

Q#39. How we can avoid duplicating records in a query?


Ans. By using DISTINCT keyword duplicating records in a query can be avoided.

Q#40. Explain the difference between Rename and Alias?


Ans. Rename is a permanent name given to a table or column whereas Alias is a temporary name
given to a table or column.
Q#41. What is a View?
Ans. A view is a virtual table which contains data from one or more tables. Views restrict data
access of table by selecting only required values and make complex queries easy.

Q#42. What are the advantages of Views?


Ans. Advantages of Views:

1. Views restrict access to the data because the view can display selective columns from the
table.
2. Views can be used to make simple queries to retrieve the results of complicated queries.
For example, views can be used to query information from multiple tables without the
user knowing.

Q#43. List the various privileges that a user can grant to another user?
Ans. SELECT, CONNECT, RESOURCES.

Q#44. What is schema?


Ans. A schema is collection of database objects of a User.

Q#45. What is Table ?


Ans. A table is the basic unit of data storage in the database management system. Table data is
stored in rows and columns.

Q#46. Do View contain Data?


Ans. No, Views are virtual structure.

Q#47. Can a View based on another View?


Ans. Yes, A View is based on another View.

Q#48. What is difference between Having clause and Where clause?


Ans. Both specify a search condition but Having clause is used only with the SELECT statement
and typically used with GROUP BY clause.
If GROUP BY clause is not used then Having behaves like WHERE clause only.

Q#49. What is difference between Local and Global temporary table?


Ans. If defined in inside a compound statement a local temporary table exists only for the
duration of that statement but a global temporary table exists permanently in the db but its rows
disappears when the connection is closed.

Q#50. What is CTE?


Ans. A CTE or common table expression is an expression which contains temporary result set
which is defined in a SQL statement.
Q#25. Difference between TRUNCATE, DELETE and
DROP commands?
Ans. DELETE removes some or all rows from a table based on the condition. It can be rolled back

TRUNCATE removes ALL rows from a table by de-allocating the memory pages. The operation
cannot be rolled back

DROP command removes a table from the database completely.

1) What is data-base testing?


Data base testing is segmented into four different categories.

 Testing of Data Integrity


 Testing of Data Validity
 Data base related performance
 Testing of functions, procedure and triggers

2) In database testing, what do we need to check normally?

Normally, the things that we check in database testing are:

 Constraint Check
 Validation of a Field size
 Stored procedure
 Matching application field size to database
 Indexes for performance based issues

3) Explain what is data driven test?


In a data-table, to test the multi numbers of data, data-driven test is used. By using this it can easily
replace the parameters at the same time from different locations.

4) What are joins and mention different types of joins?


Join is used to display two or more than two table and the types of joins are:

 Natural Join
 Inner Join
 Outer Join
 Cross Join

The outer join is divided again in two:

 Left outer join


 Right outer join

5) What are indexes and mention different types of indexes?


Indexes are database objects and they are created on columns. To fetch data quickly they are
frequently accessed. Different types of indexes are:

 B-Tree index
 Bitmap index
 Clustered index
 Covering index
 Non-unique index
 Unique index

6) While testing stored procedures what are the steps does a tester
takes?
The tester will check the standard format of the stored procedures and also it checks the fields are
correct like updates, joins, indexes, deletions as mentioned in the stored procedure.

7) How would you know for database testing, whether trigger is


fired or not?
On querying the common audit log you would know, whether, a trigger is fired or not. It is in audit
log where you can see the triggers fired.

8) In data base testing, what are the steps to test data loading?
Following steps need to follow to test data loading
 Source data should be known
 Target data should be known
 Compatibility of source and target should be checked
 In SQL Enterprise manager, run the DTS package after opening the corresponding DTS package
 You have to compare the columns of target and data source
 Number of rows of target and source should be checked
 After updating data in the source, check whether the changes appears in the target or not.
 Check NULLs and junk characters

9) Without using Database Checkpoints, how you test a SQL Query


in QTP?
By writing scripting procedure in VBScript, we can connect to database and can test the queries and
database.

10) Explain how to use SQL queries in QTP ?


In QTP using output database check point and database check, you have to select the SQL manual
queries option. After selecting the manual queries option, enter the “select” queries to fetch the data
in the database and then compare the expected and actual.

11) What is the way of writing testcases for database testing?


Writing a testcases is like functional testing. First you have to know the functional requirement of the
application. Then you have to decide the parameters for writing testcases like

 Objective: Write the objective that you would like to test


 Input method: Write the method of action or input you want to execute
 Expected: how it should appear in the database

12) To manage and manipulate the test table what are the SQL
statements that you have used in Database testing?
The statements like SELECT, INSERT, UPDATE, DELETE are used to manipulate the table, while
ALTER TABLE, CREATE TABLE and DELETE TABLE are used to manage table.
13) How to test database procedures and triggers?
To test database procedures and triggers, input and output parameters must be known. EXEC
statement can be used to run the procedure and examine the behaviour of the tables.

 Open the database project in solution explorer


 Now in View menu, click the database schema
 Open the project folder from schema View menu
 Right click on the object that has to be tested, and then click on the dialog box that says Create Unit
Tests
 After that create a new language test project
 Select either a) Insert the unit test or b) Create a new test and then click OK
 Project that has to be configured will be done by clicking on the Project Configuration dialog box.
 Once it configured click on OK

14) How you can write testcases from requirements and do


the requirements represents exact functionality of AUT
(Application Under Test)?
To write a testcases from requirements, you need to analyse the requirements thoroughly in terms of
functionality. Thereafter you think about the appropriate testcases design techniques like Equivalence
partitioning, Black box design, Cause effect graphing etc. for writing the testcases.
Yes, the requirements represent exact functionality of AUT.

15) What is DBMS?


DBMS stand for Database management system, there are different types of DBMS

 Network Model
 Hierarchical Model
 Relational Model

16) What is DML?


DML stands for Data Manipulation Language, It is used to manage data with schema objects. It is a
subset of SQL.
17) What are DCL commands? What are the two types of
commands used by DCL?
DCL stands for Data Control Language, it is used to control data.

The two types of DCL Commands are:

Grant: By using this command user can access privilege to database

Revoke: By using this command user cannot access the database

18) What is white box testing and black box testing?


Black box testing means testing the software for the outputs on giving particular inputs. This testing
is usually performed to see if the software meets the user’s requirements. There is no specific
functional output expected for running this test.

The white box testing is done to check the accuracy of code and logic of the program. This testing is
done by the programmer who knows the logical flow of the system.

19) How does QTP evaluate test results?


Once the testing is done, QTP will generate a report. This report will show the checkpoints, system
message and error that were detected while testing. The test results window will show any
mismatches encountered at the checkpoints.

20) Explain the QTP testing process?

 QTP testing process is based on following steps:


 Creating GUI (Graphical User Interface) Map files : Identifies the GUI object which has to be tested
 Creating test scripts: Test scripts are recorded
 Debug tests: Test should be debugged
 Run tests: Testcases should be run.
 View results: The results reflects the success or failure of the tests
 Report detects: If the test is failed, the reasons will be recorded in the report detect file
21) What is load testing and give some examples of it?
To measure the system response, load testing is done. If the load exceeds the users pattern it is
known as stress testing. Examples of load testing are downloading the set of large files, executing
multiple applications on a single computer, subjecting a server to large number of e-mails and
allotting many tasks to a printer one after another.

22) How to test database manually?


Testing the database manually involves checking the data at the back end and to see whether the
addition of data in front end is affecting the back end or not, and same for delete, update, insert etc.

23) What RDBMS stands for and what are the important RDMBS
that SQL use?
RDBMS stands for Relational Database Management Systems that use SQL, and the important
RDBMS that SQL uses are Sybase, Oracle, Access ,Ingres, Microsoft SQL server etc.

24) What is performance testing and what are the bottlenecks of


performance testing?
Performance testing determines the speed of the computer system performance. It includes the
quantitative tests like response time measurement. The problem in performance testing is that you
always need a well-trained and experienced man power also the tools you use are expensive.

25) What is DDL and what are their commands?


To define database structure, DDL is used. DDL stands for Data Definition Language. The various
DDL commands include Create, Truncate, Drop, Alter, Comment and Rename.

Q. How do you select all records from the table?


Select * from table_name;

Q. What is a join?
Join is a process of retrieve pieces of data from different sets (tables) and returns them
to the user or program as one “joined” collection of data.

Q. How do you add record to a table?


A. INSERT into table_name VALUES (‘ALEX’, 33 , ‘M’);
Q. How do you add a column to a table?
ALTER TABLE Department ADD (AGE, NUMBER);

Q. How do you change value of the field?


A. UPDATE EMP_table set number = 200 where item_munber = ‘CD’;
update name_table set status = 'enable' where phone = '4161112222';
update SERVICE_table set REQUEST_DATE = to_date ('2006-03-04 09:29', 'yyyy-mm-
dd hh24:MM') where phone = '4161112222';

Q. What does COMMIT do?


A. Saving all changes made by DML statements

Q. What is a primary key?


A. The column (columns) that has completely unique data throughout the table is known
as the primary key field.

Q. What are foreign keys?


A. Foreign key field is a field that links one table to another table’s primary or foreign
key.

Q. What is the main role of a primary key in a table?


A. The main role of a primary key in a data table is to maintain the internal integrity of a
data table.

Q. Can a table have more than one foreign key defined?


A table can have any number of foreign keys defined. It can have only one primary key
defined.

Q. List all the possible values that can be stored in a BOOLEAN


data field.
There are only two values that can be stored in a BOOLEAN data field: -1(true) and
0(false).

Q. What is the highest value that can be stored in a BYTE data


field?
A. The highest value that can be stored in a BYTE field is 255. or from -128 to 127. Byte
is a set of Bits that represent a single character. Usually there are 8 Bits in a Byte,
sometimes more, depending on how the measurement is being made. Each Char
requires one byte of memory and can have a value from 0 to 255 (or 0 to 11111111 in
binary).
Q. Describe how NULLs work in SQL?
The NULL is how SQL handles missing values. Arithmetic operation with NULL in SQL
will return a NULL.

Q. What is Normalization?
A. The process of table design is called normalization.

Q. What is Trigger?
A. Trigger will execute a block of procedural code against the database when a table
event occurs. A2. A trigger defines a set of actions that are performed in response to an
insert, update, or delete operation on a specified table. When such an SQL operation is
executed, in this case the trigger has been activated.

Q. Can one select a random collection of rows from a table?


Yes. Using SAMPLE clause. Example:
SELECT * FROM EMPLOYEES SAMPLE(10);
10% of rows selected randomly will be returned.

Q. You issue the following query:


SELECT FirstName FROM StaffListWHERE FirstName LIKE '_A%‘
Which names would be returned by this query? Choose all that apply.
Allen
CLARK
JACKSON
David

Q. Write a SQL SELECT query that only returns each city only
once from Students table? Do you need to order this list with an
ORDER BY clause?
A. SELECT DISTINCT City FROM Students;

Q. What is DML and DDL?


DML and DDL are subsets of SQL. DML stands for Data Manipulation Language and
DDL – Data Definition Language.
DML consist of INSERT, UPDATE and DELETE
DDL commands
CREATE TABLE, ALTER TABLE, DROP TABLE, RENAME TABLE, CREATE INDEX,
ALTER INDEX, DROP INDEX.
CREATE/ALTER/DROP VIEW

Q. Write SQL SELECT query that returns the first and last name
of each instructor, the Salary, and gives each of them a number.
A. SELECT FirstName, LastName, Salary, ROWNUM FROM Instructors;

Q. Is the WHERE clause must appear always before the GROUP


BY clause in SQL SELECT ?
A. Yes. The proper order for SQL SELECT clauses is: SELECT, FROM, WHERE,
GROUP BY, HAVING, ORDER BY. Only the SELECT and FROM clause are
mandatory.

Q. Which of the following statements are Data Manipulation Language commands?


INSERT
UPDATE
GRANT
TRUNCATE
CREATE
Ans. A and B. The INSERT and UPDATE statements are Data Manipulation Language
(DML) commands. GRANT is a Data Control Language (DCL) command. TRUNCATE
and CREATE are Data Definition Language (DDL) commands

Question: Describe SQL comments.


A. SQL comments are introduced by two consecutive hyphens (--) and ended by the
end of the line.

Q. Difference between TRUNCATE, DELETE and DROP commands?


A. The DELETE command is used to remove 'some or all rows from a table.
TRUNCATE removes ALL rows from a table. The operation cannot be rolled back
The DROP command removes a table from the database. All the tables' rows, indexes
and privileges will also be removed.

You might also like