什么是动态SQL? [英] What is dynamic SQL?

查看:886
本文介绍了什么是动态SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚问了一个与SQL有关的问题,第一个答案是:"在这种情况下,动态SQL才是可行之路."

I just asked an SQL related question, and the first answer was: "This is a situation where dynamic SQL is the way to go."

因为我以前从未听说过动态SQL ,所以我立即在此网站和网络上搜索了它的内容.维基百科没有与此标题相关的文章. Google的第一个结果都指向用户论坛,人们在这里或多或少地提出了相关问题.

As I had never heard of dynamic SQL before, I immediately searched this site and the web for what it was. Wikipedia has no article with this title. The first Google results all point to user forums where people ask more or less related questions.

但是,我没有找到关于动态SQL"的明确定义.它是特定于供应商的吗??我使用 MySQL ,但在MySQL手册中找不到参考(在MySQL用户论坛中只有问题,大多数是未回答的问题).

However, I didn't find a clear definition of what a 'dynamic SQL' is. Is it something vendor specific? I work with MySQL and I didn't find a reference in the MySQL handbook (only questions, mostly unanswered, in the MySQL user forums).

另一方面,我发现了很多关于存储过程的参考.尽管我从未使用过任何存储过程,但是我对存储过程有一个更好的了解.这两个概念是如何关联的?他们是同一件事还是一个人使用另一个人?

On the other hand, I found many references to stored procedures. I have a slightly better grasp of what stored procedures are, although I have never used any. How are the two concepts related? Are they the same thing or does one uses the other?

基本上,需要为对这个概念不熟悉的人简单地介绍动态SQL .

Basically, what is needed is a simple introduction to dynamic SQL for someone who is new to the concept.

PS:如果您愿意,可以回答我之前提示此问题的问题:

P.S.: If you feel like it, you may have a go at answering my previous question that prompted this one: SQL: How can we make a table1 JOIN table2 ON a table given in a field in table1?

推荐答案

动态SQL 只是动态构建查询的地方-对于某些供应商,您可以构建查询的文本.一个存储过程中进行动态查询,然后执行生成的SQL.在其他情况下,该术语仅是指由代码在客户端上做出的决定(至少与供应商无关)

Dynamic SQL is merely where the query has been built on the fly - with some vendors, you can build up the text of the dynamic query within one stored procedure, and then execute the generated SQL. In other cases, the term merely refers to a decision made by code on the client (this is at least vendor neutral)

这篇关于什么是动态SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆