🗄️ Database Design / Normalization
Beginner
What is a stored procedure?
Answer
A stored procedure is a pre-compiled, reusable block of SQL (and optionally procedural logic) stored in the database and executed by name. Benefits: code reuse, reduced network traffic (complex logic runs on the database server), performance (pre-compiled execution plan), and security (users execute the procedure without needing direct table access). Call with: EXEC procedure_name(param1, param2). Drawbacks: difficult to version control, test, and debug; tightly couples business logic to the database. Modern applications often move business logic to the application layer and use ORMs instead.