Today I Learned

hashrocket A Hashrocket project

character_length string function

Postgres has a character_length string function. I found this useful in check constraint scenarios:

create table addresses (
  id serial primary key,
  state text not null default 'AL' check (character_length(state) = 2)
);

https://www.postgresql.org/docs/current/static/functions-string.html

See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.