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

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

SQL Server中兩種修改對象所有者的方法

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

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

一:

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

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

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

--step3 添加hhrc用戶

--step4 運行sql,將對象權(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
?
第二種.

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

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

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

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)鍵詞標簽:SQL Server

相關(guān)閱讀

文章評論
發(fā)表評論

熱門文章 淺談JSP JDBC來連接SQL Server 2005的方法 淺談JSP JDBC來連接SQL Server 2005的方法 SqlServer2005對現(xiàn)有數(shù)據(jù)進行分區(qū)具體步驟 SqlServer2005對現(xiàn)有數(shù)據(jù)進行分區(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)下載

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