Practice SQL Questions and Answers
- Which of the following is true about a foreign key?
- In normalization, which normal form removes transitive dependencies?
- Deadlock in DBMS can be prevented using:
- Which SQL keyword is used to eliminate duplicate rows in a query result?
- Which SQL function is used to calculate the average of a numeric column?
- Which SQL clause is used to filter results after a GROUP BY operation?
- Which SQL statement combines the results of two queries and removes duplicates?
- Which SQL function returns the largest value in a column?
- Which SQL command is used to modify existing records in a table?
- Which clause is used to sort query results in SQL?
- Which SQL operator is used to search for a pattern in a column?
- Which SQL keyword is used to remove duplicate records from a query result?
- Which SQL clause is used to filter records based on aggregate functions?
- Which operator is used to combine results of two SELECT queries and remove duplicates?
- SQL Injection can be prevented by all EXCEPT:
- Which SQL clause is used to filter groups after aggregation (i.e., having aggregated value conditions)?
- Given a table employees(id, dept_id, salary), which query returns departments with average salary greater than overall average across the company?
- Which of the following SQL constructs avoids returning duplicate rows?
- Which join returns rows from the left table even when there is no matching row in the right table, filling with NULLs for the right side?
- Which index type is most beneficial for queries that use range predicates (e.g., WHERE age BETWEEN 20 AND 30)?
- Which of the following is not a type of SQL JOIN?
- What is the difference between DELETE, TRUNCATE, and DROP commands in SQL?
- In SQL, what is the difference between 'WHERE' and 'HAVING' clauses?
- In database management, which SQL command is used to retrieve only unique (non-duplicate) values from a column?
- What will be the output of the following SQL query? SELECT COUNT(*) FROM Transactions WHERE Amount > 10000 AND Status = 'Completed';
- What is a 'stored procedure' in SQL?
- Which query returns departments whose average salary is greater than 60000?
- Which SQL expression correctly returns employees whose salary is greater than the average salary of all employees?
- Orders(OrderID, CustomerID, Amount) has multiple orders per customer. Which query returns customers whose total order amount exceeds 100000?
- Table T has five rows and X values (10,20,NULL,20,NULL). What does SELECT COUNT(X) FROM T return?
- Given Employee(EmpID, Name, Salary, ManagerID), which query correctly lists employees who earn more than their own manager?
- Table B contains a NULL value in its 'id' column. Consider: SELECT * FROM A WHERE A.id NOT IN (SELECT id FROM B). What happens?
- A table has salaries 90000, 90000, 85000, 80000 (sorted descending). Using RANK() OVER (ORDER BY Salary DESC), what ranks are assigned, and how does this d...
- A table has a B-tree index on the 'Name' column. Which of the following queries is LEAST likely to benefit from this index?
- Transaction T1 runs 'SELECT COUNT(*) FROM Orders WHERE Amount > 1000' twice within the same transaction. Between the two reads, T2 inserts a new qualifying...
- Employees(emp_id, name, salary, mgr_id): (1,'Alice',9000,NULL), (2,'Bob',7000,1), (3,'Carol',9500,1), (4,'Dave',6000,2). What does the following self-join ...
- Customers(cust_id,name): (1,'A'),(2,'B'),(3,'C'). Orders(order_id,cust_id,amount): (1,1,200),(2,2,150),(3,1,300),(4,3,100). What does the following query r...
- Employees and salaries: Alice=9000, Bob=7000, Carol=9500, Dave=7000. What rank does Dave receive from the following query? SELECT name, salary, RANK() OVER...
- Table T(A,B) contains: (1,NULL), (NULL,2), (3,4), (NULL,NULL). How many rows are returned by the following query? SELECT * FROM T WHERE A=3 OR B=4;
- A view is defined as: CREATE VIEW V AS SELECT dept_id, AVG(salary) AS avg_sal FROM Employees GROUP BY dept_id; Can this view be used directly in an UPDATE ...
More Topics
- Algorithms Questions
- Analog and Digital Communication Questions
- Artificial Intelligence & Machine Language Questions
- Basics of Computers Questions
- Big Data Analytics Questions
- C Programming Questions
- C++ Questions
- Cloud Computing Questions
- Compiler Design Questions
- Computer Architecture and Design Questions
- Cyber Security Questions
- Data Analytics Languages Questions
- Data Structure Questions
- Data Warehousing Questions
- Digital Logic Questions
- Emerging Technologies Questions
- IOT and mobile Computing Questions
- IT DBMS Questions
- IT Networking Questions
- IT Operating System Questions
- Java Language Questions
- Machine Learning Questions
- Memory Management Questions
- Microsoft Office Questions
- Miscellaneous Questions Questions
- Network Layer and IP Protocol Questions
- Numerical and Statistical Computing Questions
- Object Oriented Programming Questions
- OOPS Concepts Questions
- Previous Year Questions Questions
- Programming Concept Questions
- Python Questions
- Shell Scripting Questions
- Software Engineering and Web Technology Questions
- String Manipulation Questions
- TCP IP and OSI Questions