2011-03-14 79 views
2

SQL表:什么是这些不同的SQL表的Oracle中的等价

sys.types 系统对象 syscolumns中 的sysindexes INFORMATION_SCHEMA.COLUMNS

能否也帮我这个转换为与Oracle语法

DECLARE @tableUpdateCount tinyint 
set @tableUpdateCount = 0 
/* 
* CALCDETL.ALIAS - 1 
*/ 
if exists (select * from syscolumns where id = (select id from sysobjects where name = 'ABC' and type = 'U') and name = 'ALIAS' and xusertype = (select user_type_id from sys.types where name = 'nvarchar') and prec = 20) 
begin 
    set @tableUpdateCount = @tableUpdateCount + 1 
    print ' ' 
    print '1. ABC.ALIAS exists' 
end 

是否有任何工具可以轻松地转换sql-to-oracle语法?

谢谢!

回答

2
sysobjects <-> USER_OBJECTS 
syscolumns <-> USER_TAB_COLUMNS 
sysindexes <-> USER_INDEXES 

可以使用ALL/DBA,而不是用户根据范围你想搜索的(和你的数据库角色)

Reference为更多信息。

,并检查:Oracle Functions Pl/SQL的转换

1
set ServerOutPut on; 

DECLARE 
    tableUpdateCount number(1) := 0; 
    Id number(5); 
/* 
* CALCDETL.ALIAS - 1 
*/ 
Begin 
select id into Id from syscolumns where id = (select id from sysobjects where name = 'ABC' and type = 'U') and name = 'ALIAS' and xusertype = (select user_type_id from sys.types where name = 'nvarchar') and prec = 20); 

    tableUpdateCount := tableUpdateCount + 1; 
    dbms_outPut.Put_line(''); 
    dbms_outPut.Put_line('1. ABC.ALIAS exists'); 
Exception 
    when No_Data_found then 
      dbms_outPut.Put_line('ABC.ALIAS not found'); 
End; 
相关问题