This is a finished Java implementation for the "Build Your Own SQLite" Challenge. This code implements functionality for all stages (and extentions) of the challenge as of 2025-02-22.
- Print the page size and number of tables in a sqlite3 database via the
.dbinfocommand. - Print the names of tables in a sqlite3 database via
.tables. - Do a simple
COUNT(*)operation (./your_program.sh sample.db "select count(*) from apples"). - Read data from a single column (
./your_program.sh sample.db "SELECT name FROM apples"). - Read data from multiple columns (
./your_program.sh sample.db "SELECT name, color FROM apples"). - Filter data with a
WHEREclause (only supports=operator and only compares againstTEXTorVARCHARcolumns./your_program.sh sample.db "SELECT name, color FROM apples WHERE color = 'Yellow'"). - Retrieve data with a full-table scan (
./your_program.sh superheroes.db "SELECT id, name FROM superheroes WHERE eye_color = 'Pink Eyes'"). - Retrieve data using an index (given the index exists for the table and the query is checking for equality between a
string and a single indexed column of type
TEXTorVARCHAR).
You will need Java 23 (or later) and maven installed to run this code. The program can then be run with:
./your_program.sh sample.db <command>
Note that not all functionality can be demonstrated with the included sample.db (there is no index defined on any
table).
- Add more restrictive access modifiers and rearrange packages to enable that.
- Handle
COUNT(*)more gracefully in thequerypackage.
A short video of the code being run in the codecrafters test environment: