SQL Interview Questions Notes

Jul 28, 2024

SQL Interview Questions Summary

Introduction

  • Speaker: Sahiti from Edureka
  • Focus: Top 65 SQL interview questions
  • Importance of SQL in modern data handling

Importance of SQL

  • SQL is crucial for database management.
  • Essential for aspiring Database Administrators.

Key SQL Concepts

1. Difference Between DELETE and TRUNCATE

  • DELETE: Deletes specific rows, can roll back, data manipulation command.
  • TRUNCATE: Deletes all rows, cannot roll back, data definition command, faster than DELETE.

2. Subsets of SQL

  • Data Definition Language (DDL): Defines database schema.
  • Data Manipulation Language (DML): Handles data manipulation.
  • Data Control Language (DCL): Deals with permissions and controls.
  • Transaction Control Language (TCL): Manages transaction operations.

3. Database Management Systems

  • Definition: Software for capturing and analyzing data.
  • Types:
    • Hierarchical
    • Relational
    • Network
    • Object-oriented

4. Table and Field

  • Table: Collection of data in rows and columns.
  • Field: Columns in a table.

5. Joins in SQL

  • Combines rows from two or more tables based on related columns.
  • Types:
    • Inner Join
    • Full Join
    • Left Join
    • Right Join

6. Data Types

  • CHAR vs VARCHAR:
    • CHAR: Fixed-length strings.
    • VARCHAR: Variable-length strings.

7. Primary Key

  • Uniquely identifies row in a table.
  • Can be a single attribute or a combination of attributes.

8. Constraints

  • Ensure data integrity within tables.
  • Types:
    • NOT NULL
    • UNIQUE
    • CHECK
    • DEFAULT
    • INDEX

9. SQL vs MySQL

  • SQL: Language for database management.
  • MySQL: A relational database management system.

10. Unique Key and Foreign Key

  • Unique Key: Identifies a single row, allows multiple null values.
  • Foreign Key: Maintains referential integrity between tables.

11. Data Integrity

  • Refers to accuracy and consistency of data stored in databases.

12. Indexes

  • Used for quick data retrieval.
  • Types:
    • Clustered Index: Alters data storage order.
    • Non-clustered Index: Creates a logical order.

13. SQL Queries

  • Example to display current date: SELECT GETDATE();
  • Example to find names starting with 'A': SELECT * FROM employees WHERE name LIKE 'A%';
  • Counting records: SELECT COUNT(*) FROM table_name;

14. Normalization

  • Process of organizing data to avoid redundancy.
  • Types:
    • 1NF
    • 2NF
    • 3NF
    • BCNF.

15. ACID Properties

  • Atomicity: Transactions are all or nothing.
  • Consistency: Ensures data meets validation rules.
  • Isolation: Controls concurrent transactions.
  • Durability: Ensures committed transactions persist.

16. Triggers and Procedures

  • Triggers: Automatic actions upon data modifications.
  • Stored Procedures: Precompiled collections of SQL statements.

17. Operators in SQL

  • Types include: Arithmetic, Comparison, Logical, etc.

18. SQL Functions

  • Used for data manipulation, formatting, and conversions.

19. Views

  • A virtual table combining data from one or more tables.

20. User Defined Functions

  • Types: Scalar, Inline Table-Valued, Multi-statement functions.

Conclusion

  • Acquired knowledge on SQL can significantly enhance job prospects.
  • Contact Edureka for doubts or further learning opportunities.