100% found this document useful (1 vote)
118 views4 pages

SQL Cheat Sheet 1 To 52

This document is a comprehensive SQL cheat sheet focused on data engineering, covering key concepts such as RDBMS, SQL statements, joins, functions, and database design. It includes essential topics like ACID properties, normalization, stored procedures, and performance optimization techniques. The cheat sheet serves as a quick reference for SQL-related tasks and best practices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
118 views4 pages

SQL Cheat Sheet 1 To 52

This document is a comprehensive SQL cheat sheet focused on data engineering, covering key concepts such as RDBMS, SQL statements, joins, functions, and database design. It includes essential topics like ACID properties, normalization, stored procedures, and performance optimization techniques. The cheat sheet serves as a quick reference for SQL-related tasks and best practices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL Cheat Sheet: Questions 1 to 52

(Data Engineer Focus)


1. RDBMS Concept
Tables, rows, columns. Uses primary and foreign keys. Ensures data integrity using
normalization and ACID properties.

2. Database, Schema, Table, Alias, View


Database: container; Schema: namespace; Table: rows/columns; Alias: temporary name via
AS; View: virtual table from SELECT.

3. Local & Global Temporary Tables


#Temp = local to session; ##Global = available across sessions; auto-dropped.

4. ACID Properties
Atomicity, Consistency, Isolation, Durability — ensures reliable transactions.

5. Basics of SQL
Core commands: SELECT, INSERT, UPDATE, DELETE, FROM, WHERE, ORDER BY.

6. Types of SQL Statements


DDL (CREATE), DML (INSERT), DCL (GRANT), TCL (COMMIT), DQL (SELECT).

7. Create, Delete, Update Tables


CREATE TABLE, DROP TABLE, DELETE FROM, TRUNCATE, UPDATE SET.

8. Entity, Attribute, ER Diagram


Entity: object/table; Attribute: column; Relationship: links between entities; ER diagram:
visual schema.

9. Query and Subquery


Subquery: nested SELECT in WHERE, FROM, or SELECT. Used with IN, EXISTS.

10. Nested & Correlated Subqueries


Nested = independent; Correlated = depends on outer query row.

11. SQL Constraints


PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, DEFAULT.

12. Keys and Indexes


PK = Unique + Not Null; FK = reference to PK; Composite PK = multi-column; Index =
improves performance.
13. Types of Index
Clustered (sorts data), Non-clustered (separate pointer), Unique, Composite, Full-Text.

14. Referential Integrity


FK must match PK; options: ON DELETE/UPDATE CASCADE, RESTRICT.

15. All SQL Statement Types


Same as #6 – includes DDL, DML, DCL, TCL, DQL.

16. Join Types


INNER, LEFT, RIGHT, FULL, SELF, CROSS JOIN.

17. SQL Functions


Aggregate (SUM), Scalar (LEN), String, Date, Numeric.

18. Aggregate Functions


SUM, COUNT, AVG, MIN, MAX; use with GROUP BY, HAVING.

19. Scalar Functions


Return one value per row: LEN, UPPER, GETDATE, ROUND.

20. Manipulation Functions


REPLACE, SUBSTRING, CAST, CONVERT, TRIM.

21. Analytic Functions


Use OVER(), PARTITION BY, ORDER BY; ROW_NUMBER, LAG, LEAD.

22. Ranking Functions


RANK(), DENSE_RANK(), NTILE(); used with ORDER BY.

23. Rowset Functions


OPENQUERY(), OPENROWSET() — used for external data access.

24. Local & Global Variables


@var = local; @@var = global; declared using DECLARE, SET.

25. Set Operators


UNION, UNION ALL, INTERSECT, EXCEPT — merge result sets.

26. SQL Relationship


1:1, 1:N, M:N via PK-FK relationships.

27. Normalization
1NF (Atomic), 2NF (No partial), 3NF (No transitive), BCNF.
28. De-normalization
Adds redundancy for performance; fewer joins.

29. Stored Procedures


Precompiled SQL blocks; support parameters, logic, transactions.

30. Extended Stored Proc


Call external DLLs (e.g. xp_cmdshell); system integration.

31. Recursive Stored Proc


Proc calls itself; used for hierarchy/tree structure traversal.

32. Stored Proc vs Dynamic SQL


SP = precompiled, safe; Dynamic = flexible, runtime-built.

33. Advantages of Stored Proc


Performance, security, reuse, reduced network traffic.

34. Isolation Levels


READ UNCOMMITTED, COMMITTED, REPEATABLE READ, SNAPSHOT, SERIALIZABLE —
define transaction visibility.

35. Columnstore Index


Column-wise storage, high compression, fast for OLAP, batch processing.

36. Improve Query Performance


Use indexes, avoid SELECT *, use EXISTS, optimize joins, update stats.

37. Triggers, Cursors, Event Notification


Trigger = auto-action on table; Cursor = row loop; Event = async message.

38. Deadlocks
Circular wait; resolve with consistent access order and retry logic.

39. Commits
Marks transaction as complete; COMMIT, ROLLBACK, BEGIN TRAN.

40. Lock Types


Shared = read; Exclusive = write; Update = for modifying with lock upgrade.

41. SP vs Function
SP: EXEC, allows DML, multi-action; Function: must return value, no DML.

42. SQL Server


Microsoft's RDBMS, supports T-SQL, SSMS, BI tools, Windows/Linux.
43. Database Engine
Core SQL Server service — handles storage, queries, indexing.

44. SSMA
SQL Server Migration Assistant — migrate Oracle/MySQL to SQL Server.

45. SSIS
SQL Server Integration Services — ETL, data flow, transformation, control flow.

46. OLTP vs OLAP


OLTP: real-time transactions; OLAP: analytics, aggregates, reporting.

47. Recovery Models


Simple (no log), Full (point-in-time restore), Bulk-Logged (bulk ops).

48. SSRS
SQL Server Reporting Services — report generation, charts, PDF/Excel export.

49. PolyBase
Query external sources (Hadoop, Blob) using T-SQL; supports big data.

50. Database Design


Schema planning, ER diagrams, normalization, indexing, relationships.

51. Database Models


Relational, Document, Key-Value, Graph — based on use case.

52. Data Lineage


Track data origin, transformation, flow — for audit, debugging, governance.

You might also like