Add constraint on values , Mysql

后端 未结 2 640
南笙
南笙 2021-01-26 00:01

My table

CREATE TABLE STUDENT ( 
      BCN INT not null,
      Stname varchar(50) not null,
      Sex char(1) not null ,
      primary key (BCN));
2条回答
  •  无人及你
    2021-01-26 00:48

    Use the MySQL ENUM type. "An ENUM is a string object with a value chosen from a list of permitted values that are enumerated explicitly in the column specification at table creation time."

    sex ENUM ('M', 'F')
    

提交回复
热议问题