使用SQL語句查詢資料庫資訊及表結構

2021-06-07 17:30:06 字數 341 閱讀 7977

--查詢資料庫系統中的所有資料庫

select * from master..sysdatabases

--查詢資料庫中的所有物件

select * from 庫名..sysobjects

--查詢資料庫中的所有使用者表

select * from 庫名..sysobjects where xtype = 'u'

--查詢資料表的結構

exec sp_help '表名'

select * from information_schema.columns where table_name = '表名'

exec sp_columns '表名'

sql語句查詢資料庫表結構資訊

開發中經常用到查詢指定表及其欄位的資訊,以下是我整理的sql語句查詢方法,供自己平時使用也提供給大家參考!1.適用ms sql server 1 select 2 表名 case when a.colorder 1 then d.name else end,3 表說明 case when a.col...

資料庫SQL語句查詢

新手小白菜一枚,求知 查詢所有同學的學號 姓名 選課數 總成績 select t1.stuid,t1.stuname,count t2.courseid sum score from tblstudent t1,tblscore t2 where t1.stuid t2.stuid group by...

資料庫SQL語句使用

擷取字段 string sgtoday,6,2 引數1 要擷取的字段,引數2 從第幾位擷取,引數3 擷取長度。例如 擷取folder no欄位從第一位開始的長度和fonds no相同的字段 select from folder description kj where substring folde...