国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

SQL server兩種修改對象所有者的方法,

2024-08-31 00:49:22
字體:
來源:轉載
供稿:網友


一般開發,sql server的數據庫所有者為dbo.但是為了安全,有時候可能把它換成其它的名稱.

所有者變換不是很方便.這里列出兩種供參考

一:

---******************更改權限以添加hhrc用戶*************************
--step1 添加第三方用戶,如"chn"
--step2 運行sql,加對象權限移至第三方用戶
--step3 添加hhrc用戶
--step4 運行sql,將對象權限移至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.'[email protected]
exec sp_changeobjectowner @tblown, 'chn'
print @tblname
fetch next from tbl_cur into @tblname
end
close tbl_cur
deallocate tbl_cur

第二種.
--手動修改系統表
--設備可以手動修改表
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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 天水市| 伊川县| 从化市| 文山县| 大同市| 固安县| 攀枝花市| 汉阴县| 临桂县| 曲阳县| 忻城县| 弥渡县| 平阳县| 南澳县| 东兰县| 青铜峡市| 桐城市| 穆棱市| 咸宁市| 历史| 北安市| 郯城县| 和田县| 米泉市| 孝义市| 云林县| 稻城县| 田东县| 阿拉善左旗| 邯郸县| 嘉黎县| 安阳县| 中西区| 顺昌县| 华宁县| 宝坻区| 安新县| 九寨沟县| 双峰县| 寻乌县| 卢湾区|