简体   繁体   中英

what are the equivalent of these various sql table in oracle

SQL tables:

sys.types sysobjects syscolumns sysindexes INFORMATION_SCHEMA.COLUMNS

Can you also help me convert this to oracle syntax

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

are there any tools out there that can easily convert sql-to-oracle syntax?

Thanks!

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

you can use ALL/DBA instead of USER depending on the scope you like to search in (and your Role in the Database)

See the Reference for more Info.

And Check: Oracle Functions Pl/SQL for the conversion

This will definately help you out. It's free.

Btw, for converting your SQL syntax-> Oracle syntax , you must first, go through this comparison.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM