


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Q1. What is SQL? SQL (Structured Query Language) is a standard language used to store, manage, and retrieve data from relaƟonal databases. Q2. What is a Database? A database is an organized collecƟon of data stored and accessed electronically. Q3. What is a Table? A table is a collecƟon of related data organized in rows and columns in a database. Q4. What is a Primary Key? A primary key is a column (or set of columns) that uniquely idenƟfies each row in a table. Example: EMP_ID in an employee table. Q5. What is a Foreign Key? A foreign key is a column in one table that links to the primary key of another table to maintain referenƟal integrity.
Q6. Difference between DDL, DML, DCL, and TCL? DDL (Data DefiniƟon Language): Defines structure → CREATE, ALTER, DROP, TRUNCATE DML (Data ManipulaƟon Language): Manages data → SELECT, INSERT, UPDATE, DELETE DCL (Data Control Language): Manages permissions → GRANT, REVOKE TCL (TransacƟon Control Language): Manages transacƟons → COMMIT, ROLLBACK, SAVEPOINT Q7. What is the difference between DELETE, TRUNCATE, and DROP? DELETE: Removes specific rows, can use WHERE, rollback possible TRUNCATE: Removes all rows, no WHERE, resets idenƟty, cannot rollback DROP: Removes the enƟre table (data + structure), cannot rollback
Q8. What is a Constraint in SQL? A constraint is a rule applied on a column to ensure data integrity. Examples: PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, NOT NULL, DEFAULT
Q9. What is NormalizaƟon? NormalizaƟon is the process of organizing data to reduce redundancy and improve data integrity. Example: Spliƫng customer details into separate tables like Customers, Orders, and Payments. Q10. What is a View in SQL? A view is a virtual table based on a SQL query that displays data from one or more tables without storing it physically.
Q11. What is the difference between CHAR and VARCHAR? CHAR(n): Fixed-length, always uses n characters (pads with spaces). VARCHAR(n): Variable-length, uses only needed characters. Q12. What is the difference between HAVING and WHERE? WHERE: Filters rows before grouping. HAVING: Filters groups aŌer GROUP BY.
Q13. What are Joins in SQL? Joins combine rows from two or more tables based on a related column. INNER JOIN: Returns matching rows only LEFT JOIN: Returns all rows from leŌ table + matched rows RIGHT JOIN: Returns all rows from right table + matched rows FULL JOIN: Returns all rows from both tables SELF JOIN: Table joined with itself CROSS JOIN: Returns Cartesian product of rows
Q14. What is a Subquery? A subquery is a query inside another SQL query, usually enclosed in parentheses. Q15. What are Aggregate FuncƟons in SQL? FuncƟons that return a single value for a group of rows: COUNT(), SUM(), AVG(), MAX(), MIN() Q16. What are Scalar FuncƟons in SQL? FuncƟons that return a single value for each row: LEN(), UPPER(), LOWER(), ROUND(), GETDATE()
Q25. What is the difference between RANK(), DENSE_RANK(), and ROW_NUMBER()? RANK(): Skips ranks if Ɵes. DENSE_RANK(): No skipping of ranks. ROW_NUMBER(): Unique sequence numbers without considering Ɵes. Q26. What is a CTE (Common Table Expression)? A CTE is a temporary result set used within a query.
Q27. What is Self Join? A join where a table is joined with itself. Q28. What is a Cartesian Join (Cross Join)? It returns the product of all rows from two tables. Example: 5 rows × 4 rows = 20 results.
Q29. What are Aggregate FuncƟons in SQL? COUNT(), SUM(), AVG(), MAX(), MIN() Q30. What is the difference between DELETE and TRUNCATE on idenƟty column? DELETE: Does not reset idenƟty values. TRUNCATE: Resets idenƟty to seed value.