Is there an ENUM datatype in Firebird?


There is no such type, but you can emulate almost any type with domains. For example, if you have enum allowing values 1, 3 and 7, you can define a domain like this:

CREATE DOMAIN my_enum
AS smallint CHECK (value IS NULL or VALUE IN (1,3,7));

Later you can define columns like this:

CREATE TABLE t1
(
id INTEGER,
x1 MY_ENUM,
x2 MY_ENUM NOT NULL,
...
);

For string enums, the procedure is similar:

CREATE DOMAIN db_enum
AS varchar(20) CHECK (value IS NULL or VALUE IN ('Firebird','MySQL','MSSQL'));

If you need different enums for different columns, you can define multiple domains, or simply put a check constraint on the table.


Do you find this FAQ incorrect or incomplete? Please e-mail us what needs to be changed. To ensure quality, each change is checked by our editors (and often tested on live Firebird databases), before it enters the main FAQ database. If you desire so, the changes will be credited to your name. To learn more, visit our add content page.

If you are a commercial tool maker and your tool features a great way to handle the issue written about in this FAQ, please check out our advertisement page.



All contents are copyright © 2007-2017 FirebirdFAQ.org unless otherwise stated in the text.


Links   Firebird   News   FlameRobin   Home Inventory powered by FB  
Add content   Advertise   About  

Categories
 Newbies
 SQL
 Installation and setup
 Backup and restore
 Performance
 Security
 Connectivity and API
 HOWTOs
 Errors and error codes
 Miscellaneous