什么是动态 SQL?

2023-10-27数据库问题
1

本文介绍了什么是动态 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,所以我立即搜索了该站点和网络以了解它是什么.维基百科没有具有此标题的文章.第一个谷歌结果都指向用户论坛,人们在那里提出或多或少的相关问题.

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:如果您愿意,您可以尝试回答我之前提出的问题:SQL:我们如何使 table1 JOIN table2 ON table1 中的字段中给定的表?

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?

推荐答案

Dynamic 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

Mysql目录里的ibtmp1文件过大造成磁盘占满的解决办法
ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致...
2025-01-02 数据库问题
151

按天分组的 SQL 查询
SQL query to group by day(按天分组的 SQL 查询)...
2024-04-16 数据库问题
77

SQL 子句“GROUP BY 1"是什么意思?意思是?
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)...
2024-04-16 数据库问题
62

MySQL groupwise MAX() 返回意外结果
MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)...
2024-04-16 数据库问题
13

MySQL SELECT 按组最频繁
MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)...
2024-04-16 数据库问题
16

在 Group By 查询中包含缺失的月份
Include missing months in Group By query(在 Group By 查询中包含缺失的月份)...
2024-04-16 数据库问题
12