开发者

Create a enum table and access it from other table in mysql

开发者 https://www.devze.com 2023-02-18 15:46 出处:网络
I have a table schema as follows: [enumeration] S开发者_如何学编程tatus{ good, bad, high,low } Image{

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');
0

精彩评论

暂无评论...
验证码 换一张
取 消