Marc Hoover Marc Hoover - 1 year ago 92
MySQL Question

Setting column so only 1 of 2 values are allowed

Is it possible to set a column so it can only have 1 out of 2 different values. Example, right now the type is varchar(8), but I want it so that only valid values accepted are the words "Bitcoin" or "Paypal". I know I can do this with PHP, but is it possible with MySQL?

Answer Source

Please replace with your table name and with your cloumn name

ALTER TABLE <table name>
    CHANGE COLUMN <column name> ENUM('Bitcoin','Paypal') NOT NULL;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download