MySQL query to get column names?

前端 未结 21 2192
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 01:56

I\'d like to get all of a mysql table\'s col names into an array in php?

Is there a query for this?

21条回答
  •  星月不相逢
    2020-11-22 02:34

    if you only need the field names and types (perhaps for easy copy-pasting into Excel):

    SELECT COLUMN_NAME, DATA_TYPE
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA='databasenamegoeshere'
    AND DATA_TYPE='decimal' and TABLE_NAME = 'tablenamegoeshere'
    

    remove

    DATA_TYPE='decimal'
    

    if you want all data types

提交回复
热议问题