How can I define data domain for an attribute in mysql table. For example I want 'male' or 'female' values in gender attribute of student table not any other than these. Is it possible in mysql?
質問する
1855 次
1 に答える
0
Yes it is possible, use ENUM
data-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.
e.g.
CREATE TABLE shirts (
name VARCHAR(40),
size ENUM('x-small', 'small', 'medium', 'large', 'x-large')
);
For more information look here.
于 2013-02-25T12:49:03.440 に答える