# Tables

## What is a Table?

Tables are the core unit of database [schema](/concepts/sql/schema.md). Tables are defined by a set of columns. Columns can be [primary keys](/concepts/sql/primary-key.md) 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 [constraints](/concepts/sql/constraints.md). Use `CREATE` statements to create tables and `ALTER` statements to change their schema.

## Difference between Postgres Table and Doltgres Table

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

Dolt and Postgres are [row major](https://en.wikipedia.org/wiki/Row-_and_column-major_order), meaning row values are stored next to each other. However, Postgres stores data in a binary tree structure while Dolt stores table data on disk using a content-addressed binary tree called a [prolly tree](https://docs.dolthub.com/architecture/storage-engine/prolly-tree). This setup makes Dolt [fairly comparable in query performance to Postgres](/reference/benchmarks/latency.md) 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 `select dolt_add()`.

## Example

```SQL
doltgres=> \dt
        List of relations
 Schema | Name | Type  |  Owner
--------+------+-------+----------
 public | t1   | table | postgres
(1 row)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.doltgres.com/concepts/sql/table.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
