WEB开发网
开发学院数据库Oracle Sqlserver2005迁移至Oracle系列之五:角色、用户、... 阅读

Sqlserver2005迁移至Oracle系列之五:角色、用户、及权限

 2009-03-03 13:11:13 来源:WEB开发网   
核心提示: --变量声明部分begin declare @iscreaterole int --(0.不生成角色;1.生成角色) set @iscreaterole = 1 declare @iscreateuser int --(0.不生成用户;1.生成用户) set @iscreateuser =

--变量声明部分

begin
    declare @iscreaterole int --(0.不生成角色;1.生成角色)
        set @iscreaterole = 1
    declare @iscreateuser int --(0.不生成用户;1.生成用户)
        set @iscreateuser = 1
    declare @isobjectgrant int --(0.不生成对象及系统权限;1.生成对象及系统权限)
        set @isobjectgrant = 1   
    declare @role_name sysname
    declare @role_name_grant sysname
    declare @username sysname
    declare @usernameold sysname
    declare @is_role int

    declare @grantee_name sysname
    declare @class int
    declare @object_name sysname
    declare @object_type sysname
    declare @permission_name sysname
    declare @state_desc sysname
    declare @grantorrevoke sysname
    declare @oraclepermission sysname
    declare @exec nvarchar(1000)
    declare @execgrant nvarchar(1000)

    declare @sub_object_name sysname
    declare @sub_object_type sysname
end

--创建必要的角色

if @iscreaterole = 1
begin
    declare cr_group cursor for
                                    select distinct role_name
                                    from #usergroup
                                    where    username not in  ('dbo','sys','95013')
                                            and username in (select distinct username from #usergroup where is_role = 0 )
                                            and role_name not in ('public','guest')
                                            and is_role = 1
                                    order by role_name
    open cr_group
    fetch next from cr_group into @role_name
    while @@fetch_status = 0
    begin
        print replicate(char(9),1) +  '--创建角色[' + upper(@role_name) + ']'
        print replicate(char(9),1) +  'BEGIN'
        print replicate(char(9),2) +  'VA_EXIST_USER := 0;'
        print replicate(char(9),2) +  'SELECT COUNT(ROLE) INTO VA_EXIST_USER FROM DBA_ROLES WHERE ROLE = ''' + upper(@role_name) + ''';'
        print replicate(char(9),2) +  'IF VA_EXIST_USER > 0 THEN '
        print replicate(char(9),3) +  'EXECUTE IMMEDIATE (''DROP ROLE ' + upper(@role_name) + ''');'
        print replicate(char(9),3) +  'EXECUTE IMMEDIATE (''CREATE ROLE ' + upper(@role_name) + ''');'
        print replicate(char(9),2) +  'ELSE'
        print replicate(char(9),3) +  'EXECUTE IMMEDIATE (''CREATE ROLE ' + upper(@role_name) + ''');'
        print replicate(char(9),2) +  'END IF;'
        print replicate(char(9),1) +  'END;'

上一页  1 2 3 4 5 6 7  下一页

Tags:Sqlserver 迁移 Oracle

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接