日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

数据库结构查询

發(fā)布時間:2025/3/15 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数据库结构查询 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

--1:獲取當前數(shù)據(jù)庫中的所有用戶表

select Name from sysobjects where xtype='u' and status>=0

--2:獲取某一個表的所有字段

select name from syscolumns where id=object_id(N'表名')

--3:查看與某一個表相關(guān)的視圖、存儲過程、函數(shù)

select a.* from sysobjects a, syscomments b where a.id = b.id and b.text like '%表名%'

--4:查看當前數(shù)據(jù)庫中所有存儲過程

select name as 存儲過程名稱 from sysobjects where xtype='P'

--5:查詢用戶創(chuàng)建的所有數(shù)據(jù)庫

select * from master..sysdatabases D where sid not in(select sid from master..syslogins where name='sa')

或者

select dbid, name AS DB_NAME from master..sysdatabases where sid <> 0x01

--6:查詢某一個表的字段和數(shù)據(jù)類型

select column_name,data_type from information_schema.columns
where table_name = N'表名'

--7:獲取數(shù)據(jù)庫文件路徑

select ltrim(rtrim(filename)) from 數(shù)據(jù)庫名..sysfiles where charindex('MDF',filename)>0
or
select ltrim(rtrim(filename)) from 數(shù)據(jù)庫名..sysfiles where charindex('LDF',filename)>0

?

?

--查詢數(shù)據(jù)表中的全部列名。

select name from syscolumns where id=object_id(N'數(shù)據(jù)表名') order by colorder

轉(zhuǎn)載于:https://www.cnblogs.com/fromzerotohero/p/3851764.html

總結(jié)

以上是生活随笔為你收集整理的数据库结构查询的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。