本文目錄一覽:
linux查看mysql數據表結構
一、簡單描述表結構,欄位類型
desc tabl_name;
顯示錶結構,欄位類型,主鍵,是否為空等屬性,但不顯示外鍵。
例如:desc table_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’
例如:
五、查看錶生成的DDL
show create table table_name;
例如:
這個命令雖然顯示起來不是太容易看, 這個不是問題可以用\G來結尾,使得結果容易閱讀;該命令把創建表的DDL顯示出來,於是表結構、類型,外鍵,備註全部顯示出來了。
我比較喜歡這個命令:輸入簡單,顯示結果全面。
mysql資料庫怎麼查看錶結構
登陸mysql
命令:
mysql -uroot -p
此處以mysql資料庫的func表為例
查看錶結構的方法1
命令:
desc func;
方法2
命令:
describe func;
方法3
命令:
show columns from func;
方法3
命令:
explain func;
方法3
使用mysql的工具mysqlshow.exe
mysql 資料庫 表
解決mysql查詢資料庫所有的表名稱和表結構的sql語句怎麼寫
查詢MySQL資料庫所有表名的SQL命令:
show tables;
查詢MySQL資料庫有表結構的SQL命令:
show create table tblName;
例如:show create table students;
CREATE TABLE `students` (
`sid` char(10) NOT NULL,
`sname` varchar(50) NOT NULL,
`sex` char(1) NOT NULL,
`dob` date NOT NULL,
`phone` varchar(30) DEFAULT NULL,
PRIMARY KEY (`sid`),
KEY `index_tbl1_url` (`phone`(20))
) ENGINE=InnoDB DEFAULT CHARSET=gb2312
mysql如何查看資料庫結構
1.在MySQL資料庫中通過show tables命令;查看資料庫中所有數據表
2.在MySQL資料庫中通過desc tablename;查看錶結構
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/242508.html