What kind of language is SQL?

你。 提交于 2019-12-07 13:02:32

问题


Is SQL a context free language or some other type of language?


回答1:


According to https://stackoverflow.com/a/31265136 SQL is not a regular language. The short explanation is that each select query looks like

 SELECT x FROM y WHERE z

and y can be another select query itself, so it cannot be simulated with finite-state machine. As mentioned before, there are some CFGs for SQL standarts in Backus–Naur Form, thereby SQL is nonregular context free language.




回答2:


@aquinas wrote:

Do you mean is SQL also regular? CFG's encompass regular languages. So, they aren't mutually exclusive. To answer your question though, SQL is not a regular language.

@MSX wrote:

Just to clarify, a language is context-free when it is generated by a context-free grammar. There're SQL context-free grammar definitions online. Just google around and you'll find some. Here's one, for example.



来源:https://stackoverflow.com/questions/26595394/what-kind-of-language-is-sql

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