Вы находитесь на странице: 1из 12

Identifiers

Oracle Microsoft SQL Server

Up to 30 bytes Database names up to 8


bytes

Up to 128 characters Temp table names up to


116 characters Starts with a letter, _, @, #, $ Cant contain spaces or special characters Allows quoted identifier in double-quotes or brackets

Starts with a letter Cant contain doublequote ()

Allows quoted identifier in


double-quotes

General form:
database.schema.object @server

General form:
server.database.schema. object

Datatypes
Oracle Microsoft SQL Server

CHAR VARCHAR2,
NVARCHAR2 NUMBER

CHAR VARCHAR,
NVARCHAR TINYINT, SMALLINT, INT, BIGINT, NUMERIC

DATE ROWID SYSDATE

DATETIME,
SMALLDATETIME UNIQUEIDENTIFIER and NEWID()

Datatypes (2)
Oracle Microsoft SQL Server

BFILE stores
images on a file on the file system BLOB stores images within the database

IMAGE most like


BLOB

TEXT large text


object type

CLOB text NLOB national


language text

Boolean Datatype
Oracle
declare v1 boolean := true; v2 boolean := false; begin v1 := (x>3) and v2; end;

Microsoft SQL Server


declare @v1 smallint, @v2 smallint set @v1 = /* TRUE */ 1 set @v2 = /* FALSE */ 0 begin set @v1 = case WHEN ((@x>3) and (@v2 <> /*FALSE*/ 0)) THEN /*TRUE*/ 1 ELSE /*FALSE*/ 0 end end

Tables
Oracle Microsoft SQL Server

Up to 1000 columns
per table Unlimited row size

Up to 1024 columns
per table Up to 8,060 bytes including 16 bytes to point to each text or image column Create table with SELECT INTO statement:

Create table with


SELECT statement:
create table tbl1 as select * from tbl2

select * into tbl1

Indexes
Oracle Microsoft SQL Server

Index-organized table PCTFREE index


variable

Clustered index FILLFACTOR index


option (used when the index is created) Indexes on computed columns (deterministic functions) Up to 249 indexes per table Up to 16 columns per

Indexes on functions

Unlimited table
indexes Up to 32 columns per index

Variables
Oracle Microsoft SQL Server

Doesnt require a
special prefix: declare var1 varchar2(30);

Variable names
prefixed by @: declare @var1 varchar;

Assignment:
var1 := test;

Assignment:
SET @var1 = test or SELECT @var1 = test

IF Statement
Oracle
declare v1 numeric; begin v1 := 1; if v1 > 1 then dbms_output.put_line (1>1); v1 := 100; elseif v1 > 2 then dbms_output.put_line (1 > 2); v1 := 200; else dbms_output.put_line (None); null; end if;
end;

Microsoft SQL Server


declare @v1 numeric begin set @v1 = 1 if (@v1 > 1) begin print 1>1 set @v1 = 100 end else if (@v1 > 2) begin print 1>2 set @v1 = 200 end else begin print None exec SYSDB.SYS.DB_NULL_STATEMEN T end end

LOOP Statement
Oracle Microsoft SQL Server

loop exit when rank > max_rank; do something; rank := rank + 1; end loop;

while (1 =1) begin if @rank > @max_rank break do something set @rank = @rank +1 end

WHILE Statement
Oracle Microsoft SQL Server

while rank <= max_rank loop do something; rank := rank + 1; end loop;

while (@rank <= @max_rank) begin do something set @rank = @rank +1 end

Numeric FOR Loop


Oracle Microsoft SQL Server

for rank in 1..max_rank loop do something; end loop;

declare @rank int set @rank = 1 while (@rank <= max_rank) begin do something set @rank = @rank +1 end

Cursor Attributes
Oracle Microsoft SQL Server

cursor_name%NOTF
OUND cursor_name%FOUN D cursor_name%ISOP EN

(@@FETCH_STATU
S = -1) (@@FETCH_STATU S = 0) (cursor_status (local, cursor_name) = 1) @v_cursor_name_ro wcount declared and incremented after each fetch operation

cursor_name%ROW
COUNT

Вам также может понравиться