A lightweight SQL database implementation written in Go. SQLalt provides a command-line interface to create tables, insert data, and query results with basic SQL syntax support.
- Create Tables - Define tables with custom columns and data types
- Insert Data - Add rows to tables with constraint validation
- Select Data - Query tables with WHERE clause filtering and column selection
- Persistent Storage - Data is automatically saved to JSON files
- Interactive CLI - User-friendly command-line prompt for executing SQL commands
- Data Validation - Support for NOT NULL, UNIQUE, and PRIMARY KEY constraints
git clone https://github.com/nerbrain/sqlalt.git
cd sqlalt
go buildStart the interactive prompt:
./sqlaltCREATE TABLE users (id INT PRIMARY KEY, name STRING NOT NULL, email STRING UNIQUE)Show TableINSERT INTO users (id, name, email) VALUES ('1', 'john', 'john@example.com')
INSERT INTO users (id, name, email) VALUES ('2', 'jane', 'jane@example.com')Select all rows:
SELECT * FROM usersSelect specific columns:
SELECT id, name FROM usersSelect with WHERE clause:
SELECT * FROM users WHERE id = '1'.quitor.exit- Exit the program- Any other input starting with
.- Shows an error for unrecognized commands
Tables and data are stored as JSON files in the specific database directory called data.
INT- Integer valuesSTRING- Text valuesFLOAT- Decimal numbersBOOL- Boolean values
PRIMARY KEY- Uniquely identifies each rowUNIQUE- Ensures column values are uniqueNOT NULL- Column cannot have null values
- UPDATE and DELETE statements
- JOINs between tables
- ORDER BY and GROUP BY clauses
- Index optimization
- Transaction support
- TuxCode - https://www.youtube.com/watch?v=yFGPiftpIJY
- Claude.ai