Google ExcelAutomate.com: SQL Interview Questions for Testers

SQL Interview Questions for Testers

Hi webies, rather than automation articles, I thought to give some important Interview questions and answers to my readers who are going for interview or looking for a job change....

So going forward I will post the Interview questions also in the blog...

Today I'm going to give some important SQL questions for Manual / Automation Testers faces during interview...

go through this questions and comment if you face any doubts.

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.

Q: Describe SQL comments.

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

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


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. 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. What is DML and DDL?

A.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 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. Can one select a random collection of rows from a table?

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


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. What is Normalization?

A. The process of table design is called normalization.



Q. Describe how NULLs work in SQL?

A.The NULL is how SQL handles missing values. Arithmetic operation with NULL in SQL will return a NULL.


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. List all the possible values that can be stored in a BOOLEAN data field.

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


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

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


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. 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 a primary key?

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


Q. What does COMMIT do?

A. Saving all changes made by DML statements 

Q. What is a join?

A.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 select all records from the table?
A. Select * from table_name; 



Will come up with more tricky questions...!!!!!!

1 comment:


  1. Hi There,


    Smokin hot stuff! You’ve trimmed my dim. I feel as bright and fresh as your prolific website and blogs!


    ITLE: Connect to Server
    ------------------------------
    Cannot connect to DIANA-EARH\ROMOEXPRESS.
    ------------------------------
    ADDITIONAL INFORMATION:
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections . (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476
    ------------------------------
    BUTTONS:
    OK


    It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
    Keep up the good work!


    Best Regards,
    Irene Hynes

    ReplyDelete