Tuesday, December 18, 2012

Oracle vs. SQL Server - Oracle equivalents for SQL Server DBAs

SQL Server Oracle
SELECT GETDATE() select sysdate from dual
SUBSTRING function does not take argument for starting position with negative value SUBSTR can have negative starting position in Oracle
SELECT INTO Table1
FROM Table2
CREATE Table1
AS SELECT FROM Table2
master database data dictionary
syslogins view dba_users view
sys.objects view dba_objects view
sys.tables dba_tables view
tempdb Temporary tablespace
IDENTITY field automatically incremented by 1 on INSERT Creating a sequence using:
CREATE SEQUENCE name_seq
 START WITH     1000
 INCREMENT BY   1;
and a trigger to activate the sequence on BEFORE INSERT:
CREATE OR REPLACE TRIGGER name_bir
BEFORE INSERT on TableName
FOR EACH ROW
WHEN (new.id IS NULL)
BEGIN
SELECT name_seq.NEXTVAL INTO :new.id FROM dual;
END;
ISNULL()
ISNULL(Field1, 0) returns 0 if Field1 is null
NVL()
NVL(Field1, 0) returns 0 if Field1 is null

No comments:

Post a Comment