sql和oracle的語(yǔ)法上有什么區(qū)別

sqloracle語(yǔ)法上的區(qū)別有:1、數(shù)據(jù)類型不同;2、獲得當(dāng)前系統(tǒng)時(shí)間的函數(shù)不同;3、創(chuàng)建用戶的方式不同;4、連接變量和字符串的方式不一樣;5、條件語(yǔ)句“if…else…”的語(yǔ)法不同等等。

sql和oracle的語(yǔ)法上有什么區(qū)別

sql和oracle的語(yǔ)法區(qū)別有數(shù)據(jù)類型不同,獲得當(dāng)前系統(tǒng)時(shí)間的函數(shù)不同,在oracle沒有默認(rèn)約束,連接變量和字符串的方式不一樣,case語(yǔ)句不一樣等

數(shù)據(jù)類型不同

sql server的數(shù)據(jù)類型:int ,smallint ,char,varchar,nchar,nvarchar,ntext,datetime,smalldatetime,money,decima,Float,bit

oracle 的數(shù)據(jù)類型:number(p,s),char,varchar2,Date,LOB

獲得當(dāng)前系統(tǒng)時(shí)間的函數(shù)不同

sql server:getdate()

oracle:sysdate

例如:設(shè)定日期格式的函數(shù)

to_char(sysdate,'yyy-mm-dd');

在oracle中沒有默認(rèn)約束的說(shuō)法

sql server 中添加默認(rèn)約束:

alter?table?talbe_name?add?DF_table_name?default('男')?for?sex;

oracle 中添加默認(rèn)值:

alter?table?table_name?modify(sex?default('男'));

連接變量和字符串的方式不一樣

sql server 中連接:使用“+”連接,例如:

print?'aaaa'+@name;

oracle? 中連接:使用“||”連接,例如:

dbms_output.put_line('aaa'||name);//name為變量

oracle沒有identity自動(dòng)增長(zhǎng)列,而是使用序列實(shí)現(xiàn)增長(zhǎng)

sql server 自動(dòng)增長(zhǎng):在表的主鍵列中可直接使用identity(1,1)實(shí)現(xiàn)增長(zhǎng)

oracle 使用序列自動(dòng)增長(zhǎng):

create?sequence?se_id? start?with?1 increment?by?1

使用序列實(shí)現(xiàn)自動(dòng)增長(zhǎng):se_id.nextval

條件語(yǔ)句if……else……的語(yǔ)法不同

sql server中:

??if?條件 ????????????begin ??????????????………… ????????????end ????????????else ????????????begin ??????????????………… ????????????end

oracle中:

??if?條件1?then ???????????????…………; ????????????elsif?條件2?then ???????????????…………; ????????????else ??????????????…………; ????????????end?if;

case語(yǔ)句的語(yǔ)法不同

sql server中:

select?....case.....(else)....end....語(yǔ)句 ????????????select?stuno?'學(xué)號(hào)',case ????????????when?grade&gt;=90?and?grade=80?and?grade=70?and?grade=60?and?grade<p>oracle中:</p><pre class="brush:html;toolbar:false">??declare ????????nums?number:=&amp;nos;--&amp;nos表示提示傳入值 ????????????begin ??????????????case?nums ????????????????when?100?then ??????????????????dbms_output.put_line('滿分也,不錯(cuò)'); ????????????????when?90?then ??????????????????dbms_output.put_line('90分頁(yè)很不錯(cuò)了'); ????????????????end?case; ????????????end;

創(chuàng)建用戶的方式不同

sql server中

創(chuàng)建登陸賬號(hào):sa—–123456

create?Login?登陸名稱?with?password='登陸密碼'

修改登陸賬戶:

alter?Login?登陸名稱?with?name='新登錄名稱'?and?password='新登錄密碼'

禁用/啟用登陸賬號(hào)

alter?Login?登錄名稱?disable(禁用)/enable(啟用)

刪除登陸賬號(hào)

drop?Login?登錄名稱

創(chuàng)建用戶:

create?user?用戶名?for/from?Login?登陸名稱

修改用戶名

alter?user?用戶名?with?name='新用戶名'

刪除用戶名

drop?user?用戶名

授權(quán)限

grant?select/update/delete/insert?on?表名?to?用戶名

oracle中:

創(chuàng)建用戶語(yǔ)法

create?user?用戶名 identified?by?密碼 default?tablespace?users temporary?tablespace?temp quota?10M?on?users

修改密碼

alter?user?用戶名?identified?by?新密碼

授予權(quán)限

grant?create?session?to?用戶名

刪除用戶

drop?user?用戶名?cascade;

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊6 分享