SQL内部解析的讨论 [英] discussion of internal parsing of SQL

查看:44
本文介绍了SQL内部解析的讨论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对了解如何使用SQL实际生成结果感兴趣.
我了解C ++代码如何转换为汇编代码.我了解汇编代码如何转换为机器代码.我了解CPU如何处理该机器代码,并具有一个指向机器代码的指针,并与寄存器一起使用来操纵代码.我了解算术逻辑单元等组件及其实际工作方式.我在使用IBM 360汇编器的汇编级编程中了解了这一点.我还学习了6502汇编语言.我了解通过使用工具和类似WinHook的功能进行链接和调试.我了解英特尔处理器的并行流水线.我什至了解解释性语言(例如原始的Basic和Java)和JVM,以及如何在运行时处理所有Java字节码.
我对非Von Neuman体系结构和基于依赖关系的理解不强,例如数据流处理器所使用的依赖关系.我知道有些语言(Prolog ??)具有表达式,您可以在其中定义变量之间的依赖关系,然后系统会根据该关系找到解决方案.例如,在Pro/E之类的CAD/CAD系统中,必须编写一系列必须保持的几何关系.当系统受到适当约束时,系统会生成符合约束条件的模型.
但是,现在在哪里可以很好地讨论这种情况在SQL中是如何发生的.我已经读过Hernadez的仅凡人的数据库简介",但真的不明白这种低级功能是如何实现的.
假设我们有一个名为mytable的表,其中有两列int x,int y;

I am interested in knowing how SQL is used to actually generate results.
I understand how C++ code gets translated to assembly code. I understand how assembly code gets translated into machine code. I understand how the CPU processes this machine code, has a pointer counter to the machine code and works with registers to manipulate the code. I understand components like Arithmetic Logic Units and how they actually work. I learned this in Assembly Level Programming using the IBM 360 assembler. I also learned the 6502 assembly language. I understand linking and debugging via a use of instrumentation and WinHook like functionality. I understand parellel pipelining for Intel processors. I even understand interpretive languages (like the original Basic and) Java and the JVM, and how all of the java byte code is processed at run time.
I have a weak understanding of non Von Neuman architectures and dependency based relationships like that used by that used for dataflow processors. I know that some languages (Prolog??) have expressions where you define the dependency relationships between variables and the system finds you solution based on that. For example, in CAD/CAD systems like Pro/E, one writes a series of geometic relationships which must be maintained. When the system is properly constrained, the system generates a model conforming to the constraints.
But now where was there a good discussion of how this happens for SQL. I have read Hernadez''s "An Introduction to Databases for Mere Mortals", but really don''t understand how this low level functionality is accomplished.
Suppose that we have a table called mytable, with two columns, int x, int y;

CREATE TABLE [dbo].[Transaction_Customer_Label](
    [index] [int] NOT NULL,
    [value] [nchar](8) NULL)



假设我们有一个类似
的语句



Suppose we have a statement like

SELECT * FROM tabel WHERE index=1


我有点理解,这必须解释为具有与col命名索引匹配的索引,并以某种方式将其与1.匹配.
在幕后,是否有一些代码可以将其基本上转换为某种类似的功能,例如在矩形网格中大量搜索值?

SQL语句的实际解析是如何真正完成的?
除非可以用简短的方式解释,否则我可能需要链接到文章,而不是简短的内容.


I sort of understand that this must be interpreted to something having indicies which matches the col named index with some way of cheching it against 1.
Behind the scenes, is there some code which basically converts this into something like a big search for values in a rectangular grid?

How is the actual parsing of the SQL statement really accomplished?
I probably need links to articles rather than short blurbs, unless this can be explained in something short.

推荐答案

它一点也不短,我相信你是错误地使用解析".

理解语言(任何语言)的圣经"是《龙书》,它解释了处理语言是如何发生的.那不是真实的名字,而是多年以来这样的名称,以便您甚至可以在亚马逊上搜索它.作者是Aho.

对于您的情况,发生解析后,还有其他阶段可以解释和优化以实际运行搜索. 过程基于数据库的基本数据结构和实现.

因此,要回答您的问题,您必须执行以下操作.
1.了解有关语言处理(解析,语义,代码发出,解释器等)的更多信息.
2.了解有关数据库以及它们如何组织/创建的更多信息.

如果您希望在学习了上面的一些基础知识之后,我建议您编写一个解释器,该解释器使用带有变量where子句的SQL选择"并返回结果. (除非进行选择,否则不要做其他任何事情.)
It isn''t short at all and I believe you are using "parsing" incorrectly.

The ''bible'' for understanding languages, any language, is the Dragon Book which explains how processing languages occurs. That isn''t the actual name but referred to like that for years such that you can even search for that on Amazon. The author is Aho.

For your case AFTER parsing occurs then there are other stages which interpret and optimize to actually run the search. That process is based on the fundamental data structures and implementation of the database.

So to answer your question you must do the following.
1. Learn more about language processing (parsing, semantics, code emitting, interpreters, etc.)
2. Learn more about databases and how they are organized/created.

If you wish after you learn some of the basics of the above I would suggest that you write an interpreter which takes a SQL ''select'' with a variable where clause and returns a result. (Don''t do anything else except select until you have that working.)


这篇关于SQL内部解析的讨论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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