Mysql与Sql Server查询数据库中表以及表字段
生活随笔
收集整理的這篇文章主要介紹了
Mysql与Sql Server查询数据库中表以及表字段
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1.查詢數(shù)據(jù)庫表信息
mysql查詢數(shù)據(jù)庫中所有表信息
SELECTtable_name AS '表名',table_comment AS '說明',create_time AS '創(chuàng)建時間',update_time AS '修改時間' FROMinformation_schema.TABLESsql server查詢數(shù)據(jù)庫中所有表信息
SELECTso.name AS '表名',isnull(f.value,'')AS '說明',so.create_date AS '創(chuàng)建時間',so.modify_date AS '修改時間' FROMsys.objects soLEFT JOIN sys.extended_properties f ON f.major_id = so.object_id AND f.minor_id= 0 WHEREso.type = 'U';?
2.查詢表字段信息
mysql根據(jù)表名查詢表字段信息
SELECTcolumn_name as '字段名',data_type as '類型',column_comment '說明' FROMinformation_schema.COLUMNS WHEREtable_name = 'sys_user' and table_schema = (select database()) order by ordinal_positionsql server根據(jù)表名查詢表字段信息
SELECTa.NAME as '字段名',b.NAME as '類型',g.[VALUE] as '說明' FROMsyscolumns aLEFT JOIN systypes b ON a.xusertype = b.xusertypeLEFT JOIN sys.extended_properties g ON a.id = g.major_id AND a.colid = g.minor_idINNER JOIN sysobjects d ON a.id = d.id AND d.xtype = 'U' AND d.NAME <> 'dtproperties' WHEREd.NAME = 'sys_dept'?
注:參考文檔
轉(zhuǎn)載于:https://www.cnblogs.com/cglmj/p/10943715.html
總結(jié)
以上是生活随笔為你收集整理的Mysql与Sql Server查询数据库中表以及表字段的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于Jdk7与Jdk8对Collecti
- 下一篇: 解决element-ui中el-menu