LogoLogo
BlogDiscordGitHubDoltgres
  • Introduction
    • What is Doltgres?
    • Installation
    • Getting Started
  • Concepts
    • Git
      • Commits
      • Log
      • Diff
      • Branch
      • Merge
      • Conflicts
      • Remotes
      • Working Set
    • SQL
      • Databases
      • Schema
      • Tables
      • Primary Keys
      • Types
      • Indexes
      • Views
      • Constraints
      • Triggers
      • Functions
      • Procedures
      • Users/Grants
      • Transactions
      • System Variables
    • RDBMS
      • Server
      • Backups
      • Replication
  • Guides
    • Cheat Sheet
    • Replication from Postgres
  • 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
      • Functions
      • System Tables
      • System Variables
    • SQL Language Support
      • Supported Functions and Operators
      • Supported Types
      • Supported SQL Commands
      • System Catalog Schema
    • Supported Clients
      • Programmatic
    • Benchmarks
      • Correctness
      • Latency
Powered by GitBook
On this page
  • What are Types?
  • How to use Types
  • Difference between Postgres Types and Doltgres Types
  • Interaction with Doltgres Version Control
  • Example
  1. Concepts
  2. SQL

Types

PreviousPrimary KeysNextIndexes

Last updated 11 months ago

What are Types?

A column in a SQL database has a defined type, like an integer or a string. Some databases are more strict on types than others. Postgres supports .

Types act as built in to help define the shape of your data. Are you expecting this column to be an integer or will it sometimes have decimal values? Defining the type explains to other database users the shape of the data you expected when you defined the table.

Moreover types act as a way to control the storage footprint of your database. A database must procure the maximum size of the type you define for each row when it stores your data on disk or memory.

How to use Types

Each column in your tables must have a type. You use types when defining tables. You can change the type of a column with ALTER statements.

When querying tables, the type of the column defines which functions can be used on the data retrieved. To manipulate the type of a column when querying you use the CONVERT() function.

Difference between Postgres Types and Doltgres Types

Doltgres supports , with more being implemented.

Interaction with Doltgres Version Control

A type change in Doltgres is versioned and can cause conflicts when merged. Doltgres can diff across some type changes and will make a best effort to do so.

Example

create table complex (pk1 int, pk2 varchar(47), c1 tinyint not null, c2 datetime, c3 json, primary key(pk1, pk2));
a number of types
constraints
most Postgres types