What is the difference between a stored procedure and a view?

后端 未结 10 1955
星月不相逢
星月不相逢 2020-12-04 04:59

I am confused about a few points:

  1. What is the difference between a stored procedure and a view?

  2. When should I use stored procedures, and whe

10条回答
  •  情话喂你
    2020-12-04 05:38

    Plenty of info available here

    Here is a good summary:

    A Stored Procedure:

    • Accepts parameters
    • Can NOT be used as building block in a larger query
    • Can contain several statements, loops, IF ELSE, etc.
    • Can perform modifications to one or several tables
    • Can NOT be used as the target of an INSERT, UPDATE or DELETE statement.

    A View:

    • Does NOT accept parameters
    • Can be used as building block in a larger query
    • Can contain only one single SELECT query
    • Can NOT perform modifications to any table
    • But can (sometimes) be used as the target of an INSERT, UPDATE or DELETE statement.

提交回复
热议问题