Skip to content

Instantly share code, notes, and snippets.

@BacLuc
Last active August 12, 2022 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BacLuc/0ffb97c8d32b1190b649a955134d0625 to your computer and use it in GitHub Desktop.
Save BacLuc/0ffb97c8d32b1190b649a955134d0625 to your computer and use it in GitHub Desktop.
Show which dbms support unique index on text columns with variable length
CREATE TABLE test (
test text UNIQUE,
combined_key_part1 text,
combined_key_part2 text,
CONSTRAINT combined_key_unique UNIQUE (combined_key_part1, combined_key_part2)
);
version: "3"
services:
mariadb:
image: mariadb:10.5
environment:
- MYSQL_DATABASE=db
- MYSQL_ROOT_PASSWORD=password
volumes:
- ./create-table-with-index.sql:/docker-entrypoint-initdb.d/create-table-with-index.sql
ports:
- "3306:3306"
mysql:
image: mysql:8.0.23
environment:
- MYSQL_DATABASE=db
- MYSQL_ROOT_PASSWORD=password
volumes:
- ./create-table-with-index.sql:/docker-entrypoint-initdb.d/create-table-with-index.sql
ports:
- "3307:3306"
postgres:
image: library/postgres:13.2
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=test
volumes:
- ./create-table-with-index.sql:/docker-entrypoint-initdb.d/create-table-with-index.sql
ports:
- "5432:5432"
@BacLuc
Copy link
Author

BacLuc commented Apr 6, 2021

mariadb and postgres allow unique index on text columns, mysql does not

@robertopc
Copy link

Great test! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment