WEB开发网
开发学院数据库Oracle Sqlserver2005迁移至Oracle系列之一:生成表(上) 阅读

Sqlserver2005迁移至Oracle系列之一:生成表(上)

 2009-03-03 13:11:25 来源:WEB开发网   
核心提示: --创建用户if @isuser = 1begin if @onlydeltbs = 1 insert into ##table(ident,ctext) select 1,'--删除用户[' + @user + ']' else insert into #

--创建用户

if @isuser = 1
begin
    if @onlydeltbs = 1
        insert into ##table(ident,ctext) select 1,'--删除用户[' + @user + ']'
    else
        insert into ##table(ident,ctext) select 1,'--创建用户[' + @user + ']'
    insert into ##table(ident,ctext) select 1,'DECLARE'
    insert into ##table(ident,ctext) select 2,'DMSQL VARCHAR2(512):='''';'
    insert into ##table(ident,ctext) select 2,'EXIST INT:=0;'
    insert into ##table(ident,ctext) select 1,'BEGIN'
    insert into ##table(ident,ctext) select 2,'SELECT COUNT(1) INTO EXIST FROM Dba_Users WHERE username = upper(''' + @user + ''');'
    if @onlydeltbs = 1
    begin
        insert into ##table(ident,ctext) select 2,'IF EXIST = 1 THEN'
        insert into ##table(ident,ctext) select 3,'DMSQL := ''DROP USER ' + @user + ' CASCADE'';'
        insert into ##table(ident,ctext) select 3,'EXECUTE IMMEDIATE DMSQL;'
    end
    else
    begin
        insert into ##table(ident,ctext) select 2,'IF EXIST = 0 THEN'
        insert into ##table(ident,ctext) select 3,'DMSQL := ''CREATE USER ' + @user + ' IDENTIFIED BY ' + @user + ''';'
        insert into ##table(ident,ctext) select 3,'EXECUTE IMMEDIATE DMSQL;'
        insert into ##table(ident,ctext) select 3,'DMSQL := ''GRANT DBA,UNLIMITED TABLESPACE TO ' + @user + ''';'
        insert into ##table(ident,ctext) select 3,'EXECUTE IMMEDIATE DMSQL;'
    end
    insert into ##table(ident,ctext) select 2,'END IF;'
    insert into ##table(ident,ctext) select 1,'END;'
    insert into ##table(ident,ctext) select 1,''
end

if (@istable = 0) and (@issynonym = 0) and (@isindex = 0) and (@issequence = 0)
    set @istable = @istable
else
begin
    begin

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

Tags:Sqlserver 迁移 Oracle

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