...
/Enumerations in Computational Languages
Enumerations in Computational Languages
Let’s learn about enumeration in various computational languages such as SQL, XML, and JS.
We'll cover the following...
Enumerations in SQL
Unfortunately, standard SQL does not support enumerations. Some DBMS, such as MySQL and Postgres, provide their own extensions of SQL column definitions in the CREATE TABLE
statement that define enumeration-valued columns.
A MySQL enumeration is specified as a list of enumeration labels with the keyword ENUM
within a column definition, as shown below:
Press + to interact
CREATE TABLE people (name VARCHAR(40),gender ENUM('MALE', 'FEMALE', 'UNDETERMINED'));
A Postgres enumeration is specified as a special user-defined type that can be used in column definitions:
Press + to interact
CREATE TYPE GenderEL AS ENUM ('MALE', 'FEMALE', 'UNDETERMINED');CREATE TABLE people (name text,gender GenderEL)
Enumerations in XML schema
In XML Schema, an ...