MySQL 查看錶結構簡單命令。

來源:互聯網
上載者:User

標籤:

一、簡單描述表結構,欄位類型

desc tabl_name;

顯示表結構,欄位類型,主鍵,是否為空白等屬性,但不顯示外鍵。

二、查詢表中列的注釋資訊

 

select * from information_schema.columns

where table_schema = ‘db‘  #表所在資料庫

and table_name = ‘tablename‘ ; #你要查的表

三、只查詢列名和注釋

select  column_name, column_comment from information_schema.columns where table_schema =‘db‘  and table_name = ‘tablename‘ ;

 

四、#查看錶的注釋

select table_name,table_comment from information_schema.tables  where table_schema = ‘db‘ and table_name =‘tablename‘

ps:二~四是在中繼資料表中查看,我在實際操作中,常常不靈光,不知為什麼,有瞭解的大俠請留印。

五、查看錶產生的DDL 

show create table table_name;

這個命令雖然顯示起來不是太容易看, 這個不是問題可以用\G來結尾,使得結果容易閱讀;該命令把建立表的DDL顯示出來,於是表結構、類型,外鍵,備忘全部顯示出來了。我比較喜歡這個命令:輸入簡單,顯示結果全面。

MySQL 查看錶結構簡單命令。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.