The question: Add a gender field. Ensure the field will only
accept ‘M’ or ‘F’ and the default value should be
‘F’
PostgresSQL code:
alter table Patient
add Gender varchar(1) default 'F' ,Check (Gender = 'M' or Gender = 'F');
ERROR: syntax error at or near "Check"
LINE 2: add Gender
varchar(1) default ‘F’ ,Check (Gender = ‘M’ or G…
How do i fix it?
2
Answers
Try Below
Your approach is good, there is only a small syntax error:
The second
add
was missing. UsingIN
would be typographically shorter.