I am wandering is there a way in MySQL to get the datatypes of a query columns, without executing and fetching the query rows.
In Oracle, for exapmle, you can get column datatypes (using dbms_sql.describe_columns) after parsing (dbms_sql.parse) and before executing (dbms_sql.execute) the statement, so you don't need to execute it.
Try this
SELECT column_name, data_type,character_maximum_length
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'yourTable' and TABLE_SCHEMA='yourDBname';
or for more specific result
SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'yourTable' AND COLUMN_NAME = 'yourColumn';
find more information in this link http://dev.mysql.com/doc/refman/5.0/en/columns-table.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.