2013-10-24 25 views

回答

0

你可以定義模式,只選擇需要的列:

SELECT table_schema, 
     table_name, 
     column_name, 
     data_type, 
     character_maximum_length, 
     is_nullable, 
     column_default, 
     numeric_precision, 
     numeric_scale 
    FROM information_schema.columns 
    WHERE table_name = 'yourtable' 
    AND table_schema = 'yourschema' 
ORDER BY table_schema, 
     table_name, 
     ordinal_position 
0

我有一個MySQL + PHP的解決方案去

$query = 'EXPLAIN ' . $this->tableName; 
     $statement = $this->db->prepare($query); 
     $statement->execute(); 

     while ($row = $statement->fetch()) { 
      $this->dbColumns[] = $row['Field']; 
     } 

似乎是相當快速