翻出来10年前自己写的一个玩具文本数据库,这个项目期初来自ACM月赛的一道题,然后被扩充成了这个样子。当时给取名JimSQL,寓意Jim Isn't MySQL. 现在看起来整个实现既有趣又幼稚。。。
既然是文本库,数据库则主要依赖目录及文本文件了,storage作为存储引擎。下一级目录则作为数据库,下面则是表文件
支持的数据类型,也比较简单
l INT(整型)
l STR(字符型)
l DATE(日期)
l FLOAT(附点数)
支持指令集
l use $db
l create database $name
l show database
l show tables
l create table name (filed type length , filedtype
l select * from table where field=
l describe $table;
l insert into table value(value);
整个引擎将命令匹配出来,并通过命令模式,将执行计划交给执行器。
select=net.fly78.miniSQL.dbengine.command.Select |
---|
update=net.fly78.miniSQL.dbengine.command.Update |
insert=net.fly78.miniSQL.dbengine.command.Insert |
delete=net.fly78.miniSQL.dbengine.command.Delete |
alert=net.fly78.miniSQL.dbengine.command.Alert |
show=net.fly78.miniSQL.dbengine.command.Show |
use=net.fly78.miniSQL.dbengine.command.Use |
describe=net.fly78.miniSQL.dbengine.command.Describe |
create=net.fly78.miniSQL.dbengine.command.Create |
quit=net.fly78.miniSQL.dbengine.command.Quit |
测试数据
项目地址:
https://github.com/dafei1288/jim-jack/