首页 文章资讯内容详情

应该使用哪种MySQL数据类型来存储BloodType?

2026-06-04 1 花语

要存储BloodType,请使用varchar(3)或ENUM。让我们首先创建一个表-

create table DemoTable1855 ( BloodType varchar(3) );

使用插入命令在表中插入一些记录-

insert into DemoTable1855 values(A+); insert into DemoTable1855 values(A-); insert into DemoTable1855 values(B+); insert into DemoTable1855 values(B-); insert into DemoTable1855 values(AB+);

使用select语句显示表中的所有记录-

select * from DemoTable1855;

这将产生以下输出-

+-----------+ | BloodType | +-----------+ | A+ | | A- | | B+ | | B- | | AB+ | +-----------+ 5 rows in set (0.00 sec)