我正在寻找相当于
的东西DESCRIBE USERS;
用于sql语句,例如:
SELECT id,name,md5(password) FROM USERS
主要是因为我对返回的数据类型感兴趣。
我该怎么做?
答案 0 :(得分:0)
怎么样:
select column_name,data_type, character_maximum_length, numeric_precision
from information_schema.columns
where table_name = 'USERS';
答案 1 :(得分:0)
解决方案解决方案:
CREATE TEMPORARY TABLE temp SELECT id,name,md5(password) FROM USERS;
DESCRIBE temp;
DROP TEMPORARY TABLE temp;
答案 2 :(得分:0)
此
SELECT * FROM INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA = 'schema' and TABLE_NAME = 'table'
返回大量信息。
desc INFORMATION_SCHEMA.COLUMNS
+--------------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+---------------------+------+-----+---------+-------+
| TABLE_CATALOG | varchar(512) | YES | | NULL | |
| TABLE_SCHEMA | varchar(64) | NO | | | |
| TABLE_NAME | varchar(64) | NO | | | |
| COLUMN_NAME | varchar(64) | NO | | | |
| ORDINAL_POSITION | bigint(21) unsigned | NO | | 0 | |
| COLUMN_DEFAULT | longtext | YES | | NULL | |
| IS_NULLABLE | varchar(3) | NO | | | |
| DATA_TYPE | varchar(64) | NO | | | |
| CHARACTER_MAXIMUM_LENGTH | bigint(21) unsigned | YES | | NULL | |
| CHARACTER_OCTET_LENGTH | bigint(21) unsigned | YES | | NULL | |
| NUMERIC_PRECISION | bigint(21) unsigned | YES | | NULL | |
| NUMERIC_SCALE | bigint(21) unsigned | YES | | NULL | |
| CHARACTER_SET_NAME | varchar(32) | YES | | NULL | |
| COLLATION_NAME | varchar(32) | YES | | NULL | |
| COLUMN_TYPE | longtext | NO | | NULL | |
| COLUMN_KEY | varchar(3) | NO | | | |
| EXTRA | varchar(27) | NO | | | |
| PRIVILEGES | varchar(80) | NO | | | |
| COLUMN_COMMENT | varchar(255) | NO | | | |
+--------------------------+---------------------+------+-----+---------+-------+