how to use constants in SQL CREATE TABLE?
- by kchiu
Hi,
I have 3 SQL tables, defined as follows:
CREATE TABLE organs(
abbreviation VARCHAR(16),
-- ... other stuff
);
CREATE TABLE blocks(
abbreviation VARCHAR(16),
-- ... other stuff
);
CREATE TABLE slides(
title VARCHAR(16),
-- ... other stuff
);
The 3 fields above all use VARCHAR(16) because they're related and have the same length restriction.
Is there a (preferably portable) way to put '16' into a constant / variable and reference that instead in CREATE TABLE? eg. something like this would be nice:
CREATE TABLE slides(
title VARCHAR(MAX_TITLE_LENGTH),
-- ... other stuff
);
I'm using PostgreSQL 8.4.
thanks a lot, and Happy New Year!
cheers.