Reputation: 181
Is there any way to impose a restriction on a Teradata table fields, something like this
Column Education can only contain: High School
, BS
, MS
, PhD
and nothing else. If somebody tries to INSERT
any other string, the Referential Integrity
mechanism would throw an exception
Also, is there any way to impose a restriction to the DATE
field, such that a newly inserted date must >= CURRENT_DATE
?
Thank you experts
Upvotes: 0
Views: 246
Reputation: 60482
It's the same as any other RDBMS (besides the COMPRESS part, which is Teradata only to save disk space):
datecol DATE CHECK(datecol >= CURRENT_DATE)
Maybe add a NOT NULL constraint.
education VARCHAR(11) CHECK (education IN ('High School', 'BS', 'MS', 'PhD'))
In Teradata you should add COMPRESS ('High School', 'BS', 'MS', 'PhD')
to save disk space.
Of course you could also insert the four values in a table, add a Primary Key and then a Foreign Key referencing that column...
Upvotes: 1