Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the grammatical differences between sql and oracle

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what are the grammatical differences between sql and oracle, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The grammatical differences between sql and oracle are different data types, different functions to obtain the current system time, no default constraints in oracle, different ways to concatenate variables and strings, different case statements, etc.

Different data types

Data type of sql server: int, smallint, char,varchar,nchar,nvarchar,ntext,datetime,smalldatetime,money,decima,float,bit

Data type of oracle: number (pcent s), char,varchar2,Date,LOB

Different functions to obtain the current system time

Sql server:getdate ()

Oracle:sysdate

For example: a function that sets the date format

To_char (sysdate,'yyy-mm-dd')

There is no default constraint in oracle

Add default constraints to sql server:

Alter table talbe_name add DF_table_name default ('male') for sex

Add default values to oracle:

Alter table table_name modify (sex default ('male'))

Concatenating variables and strings in a different way

Connection in sql server: use "+" connection, for example:

Print 'aaaa'+@name

Connection in oracle: use "| |" to connect, for example:

Dbms_output.put_line ('aaa' | | name); / / name is a variable

Oracle does not have identity auto-growth columns, but uses sequences to achieve growth

Sql server automatic growth: growth can be achieved directly using identity (1) in the primary key column of the table

Oracle uses the sequence to grow automatically:

Create sequence se_id start with 1increment by 1

Automatic growth using sequences: se_id.nextval

Conditional statement if... Else... The grammar is different.

In sql server:

If condition begin. End else begin. End

In oracle:

If condition 1 then. ; elsif condition 2 then. ; else. ; end if

The syntax of the case statement is different

In sql server:

Select.... case. (else).... end.... Statement select stuno 'student number', case when grade > = 90 and grade=80 and grade=70 and grade=60 and grade

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report