IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類|軟件專題|手機(jī)版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當(dāng)前所在位置: 首頁數(shù)據(jù)庫MSSQL → SQL Server中兩種修改對(duì)象所有者的方法

SQL Server中兩種修改對(duì)象所有者的方法

時(shí)間:2015-06-28 00:00:00 來源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評(píng)論(0)

一般開發(fā),SQL Server數(shù)據(jù)庫所有者為dbo.但是為了安全,有時(shí)候可能把它換成其它的名稱,所有者變換不是很方便.這里列出兩種供參考 。

一:

---******************更改權(quán)限以添加HHRC用戶*************************

--step1 添加第三方用戶,如"chn"

--step2 運(yùn)行sql,加對(duì)象權(quán)限移至第三方用戶

--step3 添加hhrc用戶

--step4 運(yùn)行sql,將對(duì)象權(quán)限移至hhrc用戶

declare @tblname varchar(30)

declare @tblown varchar(50)

declare tbl_cur cursor for

select name from sysobjects where uid='5' and status>=0 and xtype in ('U','P')

--select * from sysusers

open tbl_cur

fetch next from tbl_cur into @tblname

while @@fetch_status=0

begin

set @tblown='web56433.'+@tblname

EXEC sp_changeobjectowner @tblown, 'chn'

print @tblname

fetch next from tbl_cur into @tblname

end

close tbl_cur

deallocate tbl_cur
?
第二種.

--手動(dòng)修改系統(tǒng)表

--設(shè)備可以手動(dòng)修改表

exec sp_configure 'allow updates',1
RECONFIGURE WITH OVERRIDE
?
--更改對(duì)象所有者

update sysobjects set uid = 1 where uid = 5

update sysobjects set uid = 5 where uid = 1 AND xtype != 'S'

update sysobjects set uid = 1 where name = 'syssegments'

update sysobjects set uid = 1 where name = 'sysconstraints'

exec sp_configure 'allow updates',0

RECONFIGURE WITH OVERRIDE

關(guān)鍵詞標(biāo)簽:SQL Server

相關(guān)閱讀

文章評(píng)論
發(fā)表評(píng)論

熱門文章 淺談JSP JDBC來連接SQL Server 2005的方法 淺談JSP JDBC來連接SQL Server 2005的方法 SqlServer2005對(duì)現(xiàn)有數(shù)據(jù)進(jìn)行分區(qū)具體步驟 SqlServer2005對(duì)現(xiàn)有數(shù)據(jù)進(jìn)行分區(qū)具體步驟 sql server系統(tǒng)表損壞的解決方法 sql server系統(tǒng)表損壞的解決方法 MS-SQL2005服務(wù)器登錄名、角色、數(shù)據(jù)庫用戶、角色、架構(gòu)的關(guān)系 MS-SQL2005服務(wù)器登錄名、角色、數(shù)據(jù)庫用戶、角色、架構(gòu)的關(guān)系

相關(guān)下載

    人氣排行 配置和注冊(cè)O(shè)DBC數(shù)據(jù)源-odbc數(shù)據(jù)源配置教程 如何遠(yuǎn)程備份(還原)SQL2000數(shù)據(jù)庫 SQL2000數(shù)據(jù)庫遠(yuǎn)程導(dǎo)入(導(dǎo)出)數(shù)據(jù) SQL2000和SQL2005數(shù)據(jù)庫服務(wù)端口查看或修改 修改Sql Server唯一約束教程 SQL Server 2005降級(jí)到2000的正確操作步驟 sql server系統(tǒng)表損壞的解決方法 淺談JSP JDBC來連接SQL Server 2005的方法