溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

mysql查看字段屬性值的方法

發(fā)布時(shí)間:2020-10-24 14:29:18 來(lái)源:億速云 閱讀:906 作者:小新 欄目:MySQL數(shù)據(jù)庫(kù)

這篇文章將為大家詳細(xì)講解有關(guān)mysql查看字段屬性值的方法,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

mysql查看字段屬性值的方法:1、查詢數(shù)據(jù)庫(kù)中某個(gè)庫(kù)所有字段的屬性【table_schema= '數(shù)據(jù)庫(kù)庫(kù)名'】;2、查詢數(shù)據(jù)庫(kù)中指定庫(kù)指定表所有字段的屬性【table_schema= '數(shù)據(jù)庫(kù)庫(kù)名' and table_name= 】。

mysql查看字段屬性值的方法:

1、查詢數(shù)據(jù)庫(kù)中某個(gè)庫(kù)所有字段的屬性(指定數(shù)據(jù)庫(kù)庫(kù)名),若想查詢所有去掉where條件即可

select * from information_schema.columns 
where table_schema= '數(shù)據(jù)庫(kù)庫(kù)名'

2、查詢數(shù)據(jù)庫(kù)中指定庫(kù)指定表所有字段的屬性(指定數(shù)據(jù)庫(kù)庫(kù)名和表名)

select * from information_schema.columns 
where table_schema= '數(shù)據(jù)庫(kù)庫(kù)名' and table_name = '表名'

3、查詢數(shù)據(jù)庫(kù)中特定列條件為某個(gè)字段名的屬性

select table_schema,table_name,column_name,column_type,column_comment 
from information_schema.columns 
where TABLE_SCHEMA='數(shù)據(jù)庫(kù)名' and column_name = '字段名';

4、查詢數(shù)據(jù)庫(kù)中特定列(如:字段名、字段類型,長(zhǎng)度大小、字段注釋等)

select table_schema,table_name,column_name,column_type,column_comment from information_schema.columns 
where table_schema= '數(shù)據(jù)庫(kù)庫(kù)名'
  • table_schema:數(shù)據(jù)庫(kù)庫(kù)名

  • table_name:表名

  • column_name:字段名

  • column_type:字段屬性(包含字段類型和長(zhǎng)度)

  • column_comment :字段注釋(字段說(shuō)明)

  • data_type:字段類型

  • column_key:字段的主鍵(PRI為主鍵)

  • is_nullable:字段是否為空

關(guān)于mysql查看字段屬性值的方法就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI