Project8-Group26:基于 C++ 的简单文件数据库系统项目

25039100080孙睿一和25039100320陈绍华的小组作业

Branch1Tags0
FilesLast commitLast update
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago

项目负责人: 25039100080孙睿一 25039100080陈绍华 使用说明: 这是一个用 C++ 写的简单文件数据库系统。输入类似 SQL 的命令就可以操作数据。 每一条命令最后都要加英文分号 ;。如果没有分号,程序会认为这条命令还没写完,会继续等下一行输入。

编译:写了个cmake 在项目根目录执行: cmake -S . -B build cmake --build build

只能使用英文字母、数字和下划线命名

字段类型只支持三种: int float string

基础命令: help 查看所有支持的命令 quit / exit 退出程序 create database 库名 新建一个数据库 drop database 库名 删除一个数据库 use 库名 切换到某个数据库(操作表之前必须先切) show databases 列出所有数据库 create table 表名 (类型 字段名, ...) 在当前库里建表(类型只能是 int/float/string) drop table 表名 删除一张表 info table 表名 查看表结构(有哪些字段、什么类型) show tables 列出当前库里的所有表 insert into 表名 set 字段=值, ... 插入一条记录 delete from 表名 删除表里全部记录 delete from 表名 where 字段 比较符 值 删除满足条件的记录 select * from 表名 查询全部字段 select 字段1, 字段2 from 表名 查询指定字段 select ... where 字段 比较符 值 带条件查询 select ... order by 字段 asc/desc 排序查询(asc升序,desc降序) where 比较符: = == != < <= > >=

完整示例(从上到下跑一遍就行) create database school; use school; create table students (int id, string name, float score); insert into students set id=1, name='Alice', score=95.5; insert into students set id=2, name='Bob', score=82.0; show databases; show tables; info table students; select * from students; select name, score from students where score >= 90 order by score desc; delete from students where id = 2; select * from students; quit;

Introduction

25039100080孙睿一和25039100320陈绍华的小组作业

Customize your domain