Hacker News new | ask | show | jobs
by colanderman 2102 days ago
Postgres tip: define columns as TEXT, but with a CHECK constraint that the length is what you expect. This avoids the problem with varchar(...) that views inherit the underlying column types (including the length specifier), and prevent you from changing the maximum length in the table unless you drop and recreate the view. (There are ways around this through system tables but they are wholly unwieldy.)
1 comments

I really like that - especially since changing CHECK constraints can be done on large tables without having to rebuild the entire table.