desc foo
;打印所有列。
如何使其按字母顺序列出所有列
答案 0 :(得分:4)
您可以使用information_schema,具体取决于您想要显示的内容。
类似的东西:
SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'foo'
AND table_schema = 'foo_schema'
ORDER BY COLUMN_NAME;
答案 1 :(得分:1)
ANSI INFORMATION_SCHEMA表(in this case, INFORMATION_SCHEMA.COLUMNS)在MySQL中提供了更大的灵活性:
SELECT c.column_name FROM INFORMATION_SCHEMA.COLUMNS c WHERE c.table_name ='tbl_name' - AND c.table_schema ='db_name'
ORDER BY c.column_name