Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List available datatypes in MySQL

Tags:

sql

mysql

mariadb

How can I programmatically list all available datatypes in MySQL?

Like SELECT * FROM sys.types in MS-SQL.

I believe it is not possible, but anybody knows for sure ?

Note: I do not need only the types used as in

SELECT DISTINCT data_type FROM information_schema.columns
like image 228
Stefan Steiger Avatar asked Nov 01 '22 06:11

Stefan Steiger


1 Answers

It is not possible to programmatically list data types available in MySQL, unfortunately. MySQL doesn't have user-defined types, so it's less of a problem to hard-code a type list, as it doesn't change much (yet). Presumably when UDTs would be implemented, someone would also add an information_schema.types table. If you want to see all types currently implemented, you can check the source code sql/sql_yacc.yy e.g. for MySQL 5.6.15 here:

https://github.com/darnaut/mysql-server/blob/mysql-5.6.15/sql/sql_yacc.yy#L6399

(This assumes you can read yacc and C++ syntax.)

like image 172
jeremycole Avatar answered Nov 09 '22 14:11

jeremycole