sql命令查看表結(jié)構(gòu) mysql數(shù)據(jù)庫怎么查看表結(jié)構(gòu)?
mysql數(shù)據(jù)庫怎么查看表結(jié)構(gòu)?MySQL 查看表結(jié)構(gòu)簡單命令。 一、簡單描述表結(jié)構(gòu),字段類型desc tabl_name顯示表結(jié)構(gòu),字段類型,主鍵,是否為空等屬性,但不顯示外鍵。二、查詢表中列的注釋
mysql數(shù)據(jù)庫怎么查看表結(jié)構(gòu)?
MySQL 查看表結(jié)構(gòu)簡單命令。
一、簡單描述表結(jié)構(gòu),字段類型desc tabl_name顯示表結(jié)構(gòu),字段類型,主鍵,是否為空等屬性,但不顯示外鍵。
二、查詢表中列的注釋信息select * from information_schema.columns where table_schema = "db" #表所在數(shù)據(jù)庫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:二~四是在元數(shù)據(jù)表中查看,我在實際操作中,常常不靈光,不知為什么,有了解的大俠請留印。五、查看表生成的DDL show create table table_name
MySQL怎么查詢樹形結(jié)構(gòu)的表的數(shù)據(jù)?
當然這種結(jié)構(gòu)就不要追求什么效率了。如果要效率高的,只能改表結(jié)構(gòu)。1:select p2.id from table p1 ,table p2 where p1.id=p2.pid and p1.id=0 2:假設表名是treeSQL codeselect distinct a.id from tree as a inner join tree as b on (a.pid = b.pid) where b.pid >=0select distinct a.id from tree as a inner join tree as b on (a.pid = b.pid) where b.pid >=23.通過程序或數(shù)據(jù)庫的store procedure來實現(xiàn)了。 在mySQL中無法以一句SQL實現(xiàn)。