database - Multi valued column in SQL -
i created table boat contains following columns: bname, type, price, oname
.
however, type
column should 1 of following: sailboat, houseboat, or deckboat.
how can reflect on create table statement. i've searched , came statement i'm not sure if it's right or not:
create table boat ( bname varchar(255), btype int, price double, oname varchar(255), primary key (bname), foreign key (btype) references botype(id) ); create table botype ( id int primary key, type varchar(255) )
is best way it?
you can try this:
mycol varchar(10) not null check (mycol in('moe', 'curley', 'larry'))
here more details on mssql "check constraints":
Comments
Post a Comment