Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Alt (Alternative)

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.

Features

  • 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

Installation

git clone https://github.com/nerbrain/sqlalt.git
cd sqlalt
go build

Usage

Start the interactive prompt:

./sqlalt

Creating a Table

CREATE TABLE users (id INT PRIMARY KEY, name STRING NOT NULL, email STRING UNIQUE)

Show all Tables

Show Table

Inserting Data

INSERT INTO users (id, name, email) VALUES ('1', 'john', 'john@example.com')
INSERT INTO users (id, name, email) VALUES ('2', 'jane', 'jane@example.com')

Selecting Data

Select all rows:

SELECT * FROM users

Select specific columns:

SELECT id, name FROM users

Select with WHERE clause:

SELECT * FROM users WHERE id = '1'

Commands

  • .quit or .exit - Exit the program
  • Any other input starting with . - Shows an error for unrecognized commands

Data Storage

Tables and data are stored as JSON files in the specific database directory called data.

Supported Data Types

  • INT - Integer values
  • STRING - Text values
  • FLOAT - Decimal numbers
  • BOOL - Boolean values

Constraints

  • PRIMARY KEY - Uniquely identifies each row
  • UNIQUE - Ensures column values are unique
  • NOT NULL - Column cannot have null values

Future Enhancements

  • UPDATE and DELETE statements
  • JOINs between tables
  • ORDER BY and GROUP BY clauses
  • Index optimization
  • Transaction support

Sources used for this project

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages