Stored Procedures Vs. Views

前端 未结 7 1461
难免孤独
难免孤独 2020-12-07 16:26

I have used both but what I am not clear is when I should prefer one over the other. I mean I know stored procedure can take in parameters...but really we can still perform

7条回答
  •  孤城傲影
    2020-12-07 17:03

    Views are useful if there is a certain combination of tables, or a subset of data you consistently want to query, for example, an user joined with its permissions. Views should in fact be treated as tables.

    Stored procedures are pieces of sql code that are 'compiled', as it where, to run more optimally than a random other query. The execution plan of sql code in a stored procedure is already built, so execution runs slightly smoother than that of an ordinary sql statement.

提交回复
热议问题