C#自定义数据库引擎,如何实现SQL

时间:2022-04-21 05:36:57

As a personal project, I have been developing my own database software in C#. Many current database systems can use SQL commands for queries. Is there anyone here that could point me in the right direction of implementing such a system in a database software written completely from scratch? For example a user familiar with SQL could enter a statement as a string into an application, that statement will be analyzed by my application and the proper query will be run. Does anyone have any experience with something like that here? This is probably a very unusual questions haha. Basically what I am asking, are there any tools available out there that can dissect SQL statements or will I have to write my own from scratch for that?

作为个人项目,我一直在用C#开发自己的数据库软件。许多当前的数据库系统可以使用SQL命令进行查询。这里有没有人可以指出我在完全从头开始编写的数据库软件中实现这样一个系统的正确方向?例如,熟悉SQL的用户可以将语句作为字符串输入到应用程序中,该语句将由我的应用程序进行分析,并运行正确的查询。有没有人有这样的经历吗?这可能是一个非常不寻常的问题哈哈。基本上我要问的是,有哪些工具可以解析SQL语句,还是我必须从头开始编写自己的工具?

Thanks in advance for any help!

在此先感谢您的帮助!

(I may transfer some of my stuff to Python and Java, so any potential answers need not be limited to C#)

(我可能会把我的一些东西转移到Python和Java,所以任何潜在的答案都不必限于C#)

ALSO: I am not using any current SQL database or anything like that, my system is completely from scratch, I hope my question makes sense. Basically I want my application to be able to interface with programs that send SQL commands.

另外:我没有使用任何当前的SQL数据库或类似的东西,我的系统完全是从头开始,我希望我的问题是有道理的。基本上我希望我的应用程序能够与发送SQL命令的程序进行交互。

1 个解决方案

#1


3  

A full-on database engine is a pretty serious undertaking. You're not going to sit down and have a complete engine next week, so I'd have thought you would want to write the SQL parser piecemeal: adding features to the parser as the features are supported in the engine.

完整的数据库引擎是一项非常严肃的工作。下周你不会坐下来拥有一个完整的引擎,所以我想你会想要逐步编写SQL解析器:在解析器中添加功能,因为引擎支持这些功能。

I'm guessing this is just something fun to do, rather than something you want working ASAP. Given that, I'd have thought writing an SQL parser is one of the best bits of the project! I've done lots of work with flat file database engines, because the response times required for queries don't allow a RDBMS. One of the most enjoyable bits has been adding support for SQL fragments in e.g. the UI, where response time isn't quite as vital.

我猜这只是一件有趣的事情,而不是你想尽快工作的事情。鉴于此,我认为编写SQL解析器是项目中最好的部分之一!我在平面文件数据库引擎上做了很多工作,因为查询所需的响应时间不允许使用RDBMS。最令人愉快的一点就是在例如SQL片段中添加对SQL片段的支持。用户界面,响应时间不是那么重要。

The implementation I work on is plain old C, but in fact from what I've seen, most relational databases are still written primarily in C. And there is something satisfying about writing these things in a really low level language :)

我所使用的实现是简单的旧C,但实际上从我所看到的,大多数关系数据库仍然主要用C编写。并且有一些令人满意的用真正低级语言编写这些东西:)

#1


3  

A full-on database engine is a pretty serious undertaking. You're not going to sit down and have a complete engine next week, so I'd have thought you would want to write the SQL parser piecemeal: adding features to the parser as the features are supported in the engine.

完整的数据库引擎是一项非常严肃的工作。下周你不会坐下来拥有一个完整的引擎,所以我想你会想要逐步编写SQL解析器:在解析器中添加功能,因为引擎支持这些功能。

I'm guessing this is just something fun to do, rather than something you want working ASAP. Given that, I'd have thought writing an SQL parser is one of the best bits of the project! I've done lots of work with flat file database engines, because the response times required for queries don't allow a RDBMS. One of the most enjoyable bits has been adding support for SQL fragments in e.g. the UI, where response time isn't quite as vital.

我猜这只是一件有趣的事情,而不是你想尽快工作的事情。鉴于此,我认为编写SQL解析器是项目中最好的部分之一!我在平面文件数据库引擎上做了很多工作,因为查询所需的响应时间不允许使用RDBMS。最令人愉快的一点就是在例如SQL片段中添加对SQL片段的支持。用户界面,响应时间不是那么重要。

The implementation I work on is plain old C, but in fact from what I've seen, most relational databases are still written primarily in C. And there is something satisfying about writing these things in a really low level language :)

我所使用的实现是简单的旧C,但实际上从我所看到的,大多数关系数据库仍然主要用C编写。并且有一些令人满意的用真正低级语言编写这些东西:)