0% found this document useful (0 votes)
4 views3 pages

SQL Questions

The document contains a comprehensive list of SQL questions categorized into various topics including DDL, DML, DCL, TCL, SQL clauses, constraints, joins, and string functions. Each category features multiple questions addressing fundamental concepts, commands, and differences within SQL. This serves as a study guide for understanding SQL operations and functionalities.

Uploaded by

shreyask045
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

SQL Questions

The document contains a comprehensive list of SQL questions categorized into various topics including DDL, DML, DCL, TCL, SQL clauses, constraints, joins, and string functions. Each category features multiple questions addressing fundamental concepts, commands, and differences within SQL. This serves as a study guide for understanding SQL operations and functionalities.

Uploaded by

shreyask045
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL Questions

1. DDL (Data Definition Language)

1. What is DDL in SQL? Name all DDL commands.

2. What is the difference between CREATE and ALTER?

3. How do you delete a table structure but retain its data?

4. What is the use of TRUNCATE vs DELETE?

5. Can we modify a column to change its data type? How?

6. How do you rename a table using SQL?

7. What happens if you try to drop a table that is referenced by a foreign key?

8. Can you create a table from another existing table with structure only?

9. How do you add a default value to an existing column?

2. DML (Data Manipulation Language)

1. What is DML? List DML commands.

2. What is the difference between INSERT INTO and INSERT INTO ... SELECT?

3. How do you update multiple rows at once using UPDATE?

4. Explain how to delete duplicate rows from a table.

5. What is the difference between DELETE and TRUNCATE?

6. How can you insert data into selected columns of a table?

7. How do you insert multiple rows in a single SQL query?

8. What is MERGE in SQL? When should you use it?

3. DCL (Data Control Language)

1. What are DCL commands? Name them.

2. What is the difference between GRANT and REVOKE?

3. Can you restrict a user to only SELECT access on a particular table?

4. How do you grant permission to a user on a specific column?

5. What is the difference between roles and privileges?

6. Can we GRANT permissions on a view instead of a table?


SQL Questions

4. DTL / TCL (Transaction Control Language)

1. What is the use of COMMIT, ROLLBACK, and SAVEPOINT?

2. What is the difference between ROLLBACK TO SAVEPOINT and ROLLBACK?

3. Explain a scenario where using SAVEPOINT is useful.

4. Is TRUNCATE a transactional command?

5. What happens if an error occurs after a SAVEPOINT and before a COMMIT?

6. What is autocommit in SQL and how do you disable it?

5. SQL Clauses

1. What is the difference between WHERE and HAVING clause?

2. Can we use GROUP BY without aggregate functions?

3. What is the order of execution of SQL clauses in a query?

4. Explain the use of DISTINCT with examples.

5. What is the purpose of LIMIT and how is it different from TOP?

6. How is the IN clause different from multiple OR conditions?

7. What is the BETWEEN clause? Can it be exclusive?

8. How do wildcards work with LIKE clause?

6. Constraints

1. What are constraints in SQL? Name the different types.

2. Can a column have both UNIQUE and NOT NULL constraints?

3. Can a table have multiple FOREIGN KEY constraints?

4. What is a composite primary key?

5. What happens if a foreign key constraint is violated?

6. What is the default behavior of ON DELETE and ON UPDATE in foreign key constraints?

7. Can we drop a NOT NULL constraint from a column?

7. Joins
SQL Questions

1. What are different types of joins in SQL?

2. What is the difference between INNER JOIN and LEFT JOIN?

3. Explain SELF JOIN with an example.

4. What is the output of a CROSS JOIN?

5. When should you use FULL OUTER JOIN?

6. How to join more than two tables in SQL?

7. How do joins differ from subqueries?

8. Can we use joins with aggregate functions?

8. String Functions

1. What does the CONCAT() function do in SQL?

2. How do you convert a string to uppercase/lowercase?

3. What is the use of SUBSTRING() function?

4. Explain the use of TRIM(), LTRIM(), and RTRIM().

5. How can you find the position of a substring in a string?

6. How do you replace part of a string using SQL?

7. What is the difference between CHAR_LENGTH() and LENGTH()?

8. How can you extract the domain name from an email ID using string functions?

You might also like