每一個表中的每一列都會在information_schema.columns表中對應一行
1、informaiton_schema.columns 常用列:
1、table_catalog :不管是table | view 這個列的值總是def
2、table_schema :表 | 視圖所在的數據庫名
3、table_name :表名 | 視圖名
4、column_name :列名
5、column_default :列的默認值
6、is_nullable :是否可以取空值
7、data_type :列的數據類型
8、character_maximum_length :列的最大長度(這列只有在數據類型為char | varchar 時才有意義)
9、column_type :列類型這個類型比data_type列所指定的更加詳細,如data_type 是int 而column_type 就有可以能是int(11)
10、column_key :列上的索引類型 主鍵-->PRI | 唯一索引 -->UNI 一般索引 -->MUL
2、例子
查看tempdb 庫中的列信息
select table_schema,table_name,column_name,column_type,column_default,is_nullable,column_key from information_schema.columns where table_schema='tempdb'; +--------------+------------+-------------+-------------+----------------+-------------+------------+ | table_schema | table_name | column_name | column_type | column_default | is_nullable | column_key | +--------------+------------+-------------+-------------+----------------+-------------+------------+ | tempdb | t | x | int(11) | NULL | NO | PRI | | tempdb | t | y | varchar(32) | hello world... | NO | MUL | | tempdb | t2 | id | int(11) | NULL | NO | PRI | | tempdb | t2 | age | int(11) | 0 | NO | PRI | | tempdb | t2 | name | varchar(10) | NULL | YES | | | tempdb | v_t | x | int(11) | 0 | NO | | | tempdb | v_t | y | varchar(32) | hello world... | NO | | +--------------+------------+-------------+-------------+----------------+-------------+------------+