最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
當前位置: 首頁 - 科技 - 知識百科 - 正文

更改數(shù)據(jù)庫中表的所屬用戶的兩個方法_MySQL

來源:懂視網(wǎng) 責編:小采 時間:2020-11-09 17:16:10
文檔

更改數(shù)據(jù)庫中表的所屬用戶的兩個方法_MySQL

更改數(shù)據(jù)庫中表的所屬用戶的兩個方法_MySQL:--更改某個表exec sp_changeobjectowner 'tablename','dbo' --存儲更改全部表CREATE PROCEDURE dbo.User_ChangeObjectOwnerBatch @OldOwner as NVARCHAR(128), @NewOwner as NVARCHAR(128)AS DECLARE
推薦度:
導(dǎo)讀更改數(shù)據(jù)庫中表的所屬用戶的兩個方法_MySQL:--更改某個表exec sp_changeobjectowner 'tablename','dbo' --存儲更改全部表CREATE PROCEDURE dbo.User_ChangeObjectOwnerBatch @OldOwner as NVARCHAR(128), @NewOwner as NVARCHAR(128)AS DECLARE

--更改某個表
exec sp_changeobjectowner 'tablename','dbo'


--存儲更改全部表
CREATE PROCEDURE dbo.User_ChangeObjectOwnerBatch
@OldOwner as NVARCHAR(128),
@NewOwner as NVARCHAR(128)
AS

DECLARE @Name as NVARCHAR(128)
DECLARE @Owner as NVARCHAR(128)
DECLARE @OwnerName as NVARCHAR(128)

DECLARE curObject CURSOR FOR
select 'Name' = name,
'Owner' = user_name(uid)
from sysobjects
where user_name(uid)=@OldOwner
order by name

OPEN curObject
FETCH NEXT FROM curObject INTO @Name, @Owner
WHILE(@@FETCH_STATUS=0)
BEGIN
if @Owner=@OldOwner
begin
set @OwnerName = @OldOwner '.' rtrim(@Name)
exec sp_changeobjectowner @OwnerName, @NewOwner
end
-- select @name,@NewOwner,@OldOwner

FETCH NEXT FROM curObject INTO @Name, @Owner
END

close curObject
deallocate curObject


GO

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

更改數(shù)據(jù)庫中表的所屬用戶的兩個方法_MySQL

更改數(shù)據(jù)庫中表的所屬用戶的兩個方法_MySQL:--更改某個表exec sp_changeobjectowner 'tablename','dbo' --存儲更改全部表CREATE PROCEDURE dbo.User_ChangeObjectOwnerBatch @OldOwner as NVARCHAR(128), @NewOwner as NVARCHAR(128)AS DECLARE
推薦度:
標簽: 更改 修改 兩個
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top