Question
Difference between Store procedure & View ?
A
Anonymous
December 21, 2025

Answer

View

  1. A View is a virtual table created using a SQL SELECT statement.
  2. It does not store data itself (except indexed/materialized views); it only stores the query.


Key Points

  1. Read-only in most cases
  2. Simplifies complex queries
  3. Improves readability and reuse
  4. Enforces data abstraction and security

Example


CREATE VIEW active_employees AS
SELECT emp_id, name, dept_id
FROM employee
WHERE status = 'ACTIVE';


Stored Procedure

A Stored Procedure is a compiled set of SQL statements stored in the database that can:

  1. Perform CRUD operations
  2. Contain business logic
  3. Accept input/output parameters
  4. Handle transactions and error handling


Example

CREATE PROCEDURE create_employee(
IN p_name VARCHAR(100),
IN p_dept_id INT
)
BEGIN
INSERT INTO employee(name, dept_id)
VALUES (p_name, p_dept_id);
SELECT *FROM employeel
END;


In summary, A View is a virtual, read-only table used for simplified data access and reporting, while a Stored Procedure is an executable database program used for complex logic, transactions, and data manipulation.

JuniorDatabase
Loading comments...
Difference between Store procedure & View ? — Database Appian Interview Question | Appian Interview Questions - AppianVerse