Mysql檢視表結構資訊

2021-06-21 04:08:33 字數 1992 閱讀 5641

檢視所有的庫

select lower(schema_name) schema_name

from information_schema.schemata

where schema_name not in (

'mysql',

'information_schema',

'test',

'search',

'tbsearch',

'sbtest',

'dev_ddl'

)檢視某乙個庫中的所有表

select table_name,

create_time updated_at,

table_type,

engine,

table_rows num_rows,

table_comment,

ceil(data_length / 1024 / 1024) store_capacity

from information_schema.tables

where table_schema = 'employees'

and table_name not like 'tmp#_%' escape '#'

檢視某乙個庫下某乙個表的所有字段

select lower(column_name) column_name,

ordinal_position position,

column_default ****ult_value,

substring(is_nullable, 1, 1) nullable,

column_type data_type,

column_comment,

character_maximum_length data_length,

numeric_precision data_precision,

numeric_scale data_scale

from information_schema.columns

where table_schema = 'employees'

and table_name = 'employees';

檢視某乙個庫下某一張表的索引

select distinct

lower(index_name) index_name,

lower(index_type) type

from information_schema.statistics

where table_schema = 'employees'

and table_name = 'employees';

檢視某乙個庫下某一張表的某乙個索引

select lower(column_name) column_name,

seq_in_index column_position

from information_schema.statistics

where table_schema = 'employees'

and table_name = 'employees'

and index_name = 'primary';

檢視某乙個庫下某乙個表的注釋

select table_comment comments

from information_schema.tables

where table_schema = 'employees'

and table_name = 'tablename';

檢視某乙個庫下某乙個表的列的注釋

select lower(column_name) column_name,  

column_comment comments  

from information_schema.columns

where table_schema ='databasename'

and table_name = 'tablename';

mysql檢視表結構索引 mysql檢視表結構命令

mysql檢視表結構命令,如下 desc 表名 show columns from 表名 describe 表名 show create table 表名 use information schema select from columns where table name 表名 順便記下 show...

mysql 檢視表結構

連線到mysql d mysql 5.6.10 winx64 bin mysql h192.168.1.1 u root proot hip u使用者名稱 p密碼 url 檢視表結構 url quote 檢視表結構資訊 本人相看,得到相同的結果 1.desc 表名 2.show columns fr...

Mysql 檢視表結構

i 簡單描述表結構,字段型別 desc tabl name 顯示表結構,字段型別,主鍵,是否為空等屬性,但不顯示外來鍵。ii 查詢表中列的注釋資訊 select from information schema.columns where table schema db 表所在資料庫 and tabl...