Create a enum table and access it from other table in mysql
I have a table schema as follows:
[enumeration]
S开发者_如何学编程tatus{
good, bad, high,low
}
Image{
id :string name: string quality : Status
}
I have found that enum Table can be created as:
Create Table Status{ status enum ('good','bad','high','low') };
My question: Do i need to create a column for a table Status? How can i refer it in other table while creating a table schema?
You don't need a table for status. You declare a status enum column in your image table. Like so:
create table testo (status enum('foo', 'bar', 'baz'));
insert into testo(status) values('foo');
精彩评论