Skip to content
Advertisement

Data Type for Lists

I’m creating a table and one of the requirements is that the only option that can be entered are QLD, NSW, VIC, SA, WA, NT and ACT (Australian states). What is this datatype and how is written in SQL, thanks.

Advertisement

Answer

The type is ENUM, and you should create your table like this:

CREATE TABLE states (
    name VARCHAR(10),
    sta ENUM('QLD', 'NSW', 'VIC', 'SA', 'WA', 'NT', 'ACT')
);
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement