LogoLogo
DoltHubBlogDiscordGitHubDolt
  • Introduction
    • What Is Dolt?
    • Installation
      • Linux
      • Windows
      • Mac
      • Build from Source
      • Application Server
      • Docker
      • Upgrading
    • Getting Started
      • Version Controlled Database
      • Git For Data
      • Versioned MySQL Replica
    • Use Cases
      • Data Sharing
      • Data and Model Quality Control
      • Manual Data Curation
      • Version Control for your Application
      • Versioned MySQL Replica
      • Audit
      • Configuration Management
      • Offline First
  • Concepts
    • Dolt
      • Git
        • Commits
        • Log
        • Diff
        • Branch
        • Merge
        • Conflicts
        • Remotes
        • Working Set
      • SQL
        • Databases
        • Schema
        • Tables
        • Primary Keys
        • Types
        • Indexes
        • Views
        • Constraints
        • Triggers
        • Procedures
        • Users/Grants
        • Transactions
        • System Variables
      • RDBMS
        • Server
        • Backups
        • Replication
    • DoltHub/DoltLab
      • Permissions
      • Pull Requests
      • Issues
      • Forks
  • SQL Reference
    • Running the Server
      • Configuration
      • Access Management
      • Branch Permissions
      • Backups
      • Garbage Collection
      • Metrics
      • Replication
      • Troubleshooting
    • Version Control Features
      • Using Branches
      • Merges
      • Querying History
      • Using Remotes
      • Procedures
      • Functions
      • System Tables
      • System Variables
      • Saved Queries
    • SQL Language Support
      • Data Description
      • Expressions, Functions, Operators
      • Supported Statements
      • MySQL Information Schema
      • Collations and Character Sets
      • System Variables
      • Miscellaneous
    • Supported Clients
      • Programmatic
      • SQL Editors
    • Benchmarks and Metrics
      • Correctness
      • Latency
      • Import
  • CLI Reference
    • Commands
    • Git Comparison
  • Architecture
    • Overview
    • Storage Engine
      • Commit Graph
      • Prolly Trees
      • Block Store
    • SQL
      • Go MySQL Server
      • Vitess
  • Guides
    • Cheat Sheet
    • Contributing
      • dolt
      • go-mysql-server
    • MySQL to Dolt Replication
    • Importing Data
    • Integrations
  • Other
    • FAQ
    • Roadmap
    • Versioning
  • Products
    • Hosted Dolt
      • Getting Started
      • Notable Features
      • SQL Workbench
      • Cloning a Hosted Database
      • Using DoltHub as a Remote
      • Infrastructure
    • DoltHub
      • Data Sharing
      • API
        • Authentication
        • SQL
        • CSV
        • Database
        • Hooks
      • Continuous Integration
        • Getting Started
        • Workflow Reference
      • Transform File Uploads
      • Workspaces
    • DoltLab
    • Dolt Workbench
    • DoltgreSQL
Powered by GitBook
On this page
  • What is a Table?
  • How to use Tables
  • Difference between MySQL Table and Dolt Table
  • Interaction with Dolt Version Control
  • Example

Was this helpful?

Edit on GitHub
Export as PDF
  1. Concepts
  2. Dolt
  3. SQL

Tables

PreviousSchemaNextPrimary Keys

Last updated 1 year ago

Was this helpful?

What is a Table?

Tables are the core unit of database . Tables are defined by a set of columns. Columns can be which act as a unique identifier for each row. Once a table schema is defined, rows containing data can be inserted into the table.

Table data is stored on disk. The way a database lays out it's table data on disk defines some of the performance characteristics of the database.

How to use Tables

Structure the data in your database into tables. Define relationships between tables using foreign key . Use CREATE statements to create tables and ALTER statements to change their schema.

Difference between MySQL Table and Dolt Table

A MySQL and Dolt table function the same on the surface. CREATE and ALTER statements work the same on both.

Dolt and MySQL are , meaning row values are stored next to each other. However, MySQL stores data in a binary tree structure while Dolt stores table data on disk using a content-addressed binary tree called a . This setup makes Dolt while also providing history-independence and fast diff between versions. Fast diff powers Dolt's version control capabilities.

Interaction with Dolt Version Control

Dolt versions table schema and data. A table in Dolt is akin to a file in Git, it is the unit of change. Tables are the target of dolt add.

Example

mysql> show tables;
+----------------+
| Tables_in_docs |
+----------------+
| complex        |
| docs           |
+----------------+
mysql> alter table complex add column c4 blob;
mysql> show create table complex;
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                                                                                                                                                                                  |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| complex | CREATE TABLE `complex` (
  `pk1` int NOT NULL,
  `pk2` varchar(47) NOT NULL,
  `c1` tinyint NOT NULL,
  `c2` datetime,
  `c3` json,
  `c4` blob,
  PRIMARY KEY (`pk1`,`pk2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
schema
primary keys
constraints
row major
prolly tree
fairly comparable in query performance to MySQL