What is a dynamic SQL query, and when would I want to use one?

半世苍凉 提交于 2019-12-05 00:05:43
Kyle Rozendo

Here's a few articles:

From Introduction to Dynamic SQL:

Dynamic SQL is a term used to mean SQL code that is generated programatically (in part or fully) by your program before it is executed. As a result it is a very flexible and powerful tool. You can use dynamic SQL to accomplish tasks such as adding where clauses to a search based on what fields are filled out on a form or to create tables with varying names.

Dynamic SQL is SQL generated by the calling program. This can be through an ORM tool, or ad-hoc by concatenating strings. Non-dynamic SQL would be something like a stored procedure, where the SQL to be executed is predefined. Not all DBA's will let you run dynamic SQL against their database due to security concerns.

lexu

A dynamic SQL query is one that is built as the program is running as opposed to a query that is already (hard-) coded at compile time.

The program in question might be running either on the client or application server (debatable if you'd still call it 'dynamic') or within the database server.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!