Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我想添加一个只能是两个值的列,例如,一个名为“性别”的列,其中有两个可能的选项“男性”或“女性”
采用CHECK
CHECK
Gender VARCHAR(6) NOT NULL CHECK (Gender IN ('Male', 'Female'))
我可能想使用位字段类型,并且不允许空值,因此该值只能是 0 或 1(真/假)。
create table abc ( Gender Varchar(10) check (gender in ('Female','Male'))