--sql server 与  oracle的区别:

--DBMS 数据库管理系统
--1.数据类型不同。
      --sql server 的数据类型:int ,smallint ,char,varchar,nchar,nvarchar,ntext,datetime,smalldatetime,money,decima,
      --float,bit……
      
      
      --oracle 的数据类型:number(p,s),char,varchar2,Date,LOB
               --注意:insert into table_name values('1','张三','男',date'2012-3-5');---插入字符串日期前加date转换类型
      
--2.获得当前系统时间的函数不同。
      --sql server :getdate()
      
      --oracle:sysdate
            --例如:设定日期格式的函数:to_char(sysdate,'yyy-mm-dd');
--3.在oracle中没有默认约束的说法
      --sql server 中添加默认约束:alter table talbe_name add DF_table_name default('男') for sex;
      
      --oracle 中添加默认值:alter table table_name modify(sex default('男'));

--4.连接变量和字符串的方式不一样
      --sql server 中连接:使用“+”连接,例如:print 'aaaa'+@name;
      
      --oracle  中连接:使用“||”连接,例如:dbms_output.put_line('aaa'||name);---name为变量
 
--5.oracle没有identity自动增长列,而是使用序列实现增长
      --sql server 自动增长:在表的主键列中可直接使用identity(1,1)实现增长
      
      --oracle 使用序列自动增长:
                                 create sequence se_id 
                                 start with 1
                                 increment by 1
      --使用序列实现自动增长:se_id.nextval
--6.条件语句if……else……的语法不同
      --sql server中:
            if 条件
            begin
              …………
            end
            else
            begin
              …………
            end 
      --oracle中:
            if 条件1 then
               …………;
            elsif 条件2 then
               …………;
            else
              …………;
            end if;
            
--7.case语句的语法不同
      --sql server中:
            --select ....case.....(else)....end....语句
            select stuno '学号',case
            when grade>=90 and grade<=100 then '★★★★'
            when grade>=80 and grade<90 then '★★★'
         when grade>=70 and grade<80 then '★★'
         when grade>=60 and grade<70  then '★'
            else '差'
            end as '等级' from score            go      --oracle中:
            declare
               nums number:=&nos;--&nos表示提示传入值
            begin
              case nums
                when 100 then
                  dbms_output.put_line('满分也,不错');
                when 90 then
                  dbms_output.put_line('90分页很不错了');
                end case;
            end;
--8.触发器创建语法不同
     --sql server中:
     
         --首先判断触发器是否已经存在
         if exists (select * from sys.sysobjects where name='tr_delete')
    --如果存在先删除
    drop trigger tr_delete
         go
         
        --创建触发器
        create trigger tr_delete
        on bookInfo
        instead of delete
        as
            --定义变量
            declare @bookid int 
            select @bookid=Bookid from deleted---deleted执行删除语句( delete from BookInfo where BookId=1),自动生成的deleted表
            --删除与该图书的相关记录(先删除从表再删除主表)
            delete from borrowinfo where  bookid=@bookid
            delete from backinfo where  bookid=@bookid
            delete from BookInfo where BookId=@bookid
            --判断
            if @@error<>0
            begin
                print '删除失败'
                rollback transaction
            end
            else
            begin
                print '删除成功'
            end
        go
        delete from BookInfo where BookId=1        
         
     --oracle中:
        --创建触发器
        create or replace trigger tri_test
        before insert or update or delete 
        on table_name
        [for each row]---如果要使用 :new /:old 就必须使用行触发器
        declare
             nums varchar2(20);
        begin
          select 'F'||lpad('aa',5,0) into nums from dual;
        end;
     
--9.oracle中的存储过程
            --sql server中存储过程:
            
            --判断存储过程是否已经存在
            if exists(select * from sys.sysobjects where name='proc_name')
     --如果存在先删除
     drop proc proc_name
            go
            
            --创建存储过程语句
            create proc/procedure proc_name
            @参数名1 数据类型 [out/output],
            @参数名2 数据类型 [out/output]
            as
                  …………
            go
            
            --调用存储过程
            --如果有输出参数,则需定义变量(假设@参数2为输出参数)
            declare @变量名 数据类型
            exec proc_name @参数名1='aaa',@参数名2=@变量名 out
            
            
            ---oracle中带游标及循环的存储过程
            
             create or replace procedure proc_selCurrent
             (
                    names varchar2
             )
             as
                    cursor cursor_sel
                    is
                    select DepositSum,cardType,name,state from CurrentAccount where name like '%'||names||'%';
                    dd number;
                    cc number;
                    nn varchar2(20);
                    sta number;
                    begin
                      open cursor_sel;
                           loop
                             fetch cursor_sel into dd,cc,nn,sta;
                             dbms_output.put_line('存款金额:'||dd||'姓名:'||nn);
                           exit when cursor_sel%notfound;
                           end loop;
                      close cursor_sel;
                    end;
                    
              --调用存储过程
              begin
                proc_selCurrent('a');
              end;
                      
--10.创建用户的方式不同
       --sql server中
           --1、创建登陆账号:sa-----123456
                 create Login 登陆名称 with password='登陆密码'
                 
           --修改登陆账户:
                 alter Login 登陆名称 with name='新登录名称' and password='新登录密码'
           --禁用/启用登陆账号
                 alter Login 登录名称 disable(禁用)/enable(启用)
           --删除登陆账号
                 drop Login 登录名称
                 
           --2、创建用户:
            create user 用户名 for/from Login 登陆名称
            
            --修改用户名
            alter user 用户名 with name='新用户名'
            
            --删除用户名
            drop user 用户名
            
            ---授权限
            grant select/update/delete/insert on 表名 to 用户名
              
            
        ---oracle中:
        
            ---创建用户语法:
                  create user 用户名
                  identified by 密码
                  default tablespace users
                  temporary tablespace temp
                  quota 10M on users
                  
                  --修改密码:
                  alter user 用户名 identified by 新密码
                  
                  --授予权限:
                  grant create session to 用户名
                  
                  --删除用户
                  drop user 用户名 cascade;
                  
                  
           自己总结的一点,仅供参考

Oracle 和 SqlServer 的区别的更多相关文章

  1. oracle与sqlserver部分区别

    oracle和sqlserver的区别:1,执行修改操作要接commit,不然数据仅仅只是查看,并不是提交数据2,oracle不能使用select 字段 这种查看方式查看数据:3,oracle存储过程 ...

  2. Oracle/Mysql/SqlServer函数区别

    mysql日期和时间格式转换 Linux scp 使用详解 Oracle/Mysql/SqlServer函数区别 2011-07-01 12:34:36|  分类: Mysql技术 |  标签:mys ...

  3. Oracle、SqlServer——基础知识——oracle 与 SqlServer 的区别(未完工)

    一. oracle 与 SqlServer 的区别: 类别 oracle SqlServer 连接字符串 || + 变量 变量名 @变量名 初始赋值 := = SQL语句赋值 into = 绑定变量 ...

  4. MySQL、Oracle、SqlServer的区别

    鉴于和数据库打交道日益频繁,遂决定写一篇关于Oracle.SqlServer.MySQL区别的个人观点. MySQL是大学时的主要学习对象,但刚参加工作时转到了SqlServer,现在主要接触的是Or ...

  5. Oracle 与 SqlServer 的区别浅析总结

    我主要用过的数据库为Oracle10g和SqlServer2008,通过实际运用和查阅资料整理如下: 主题 Oracle 10g SQLServer 2008 存储过程格式 Create Or Rep ...

  6. 如何将两个字段合成一个字段显示(oracle和sqlserver的区别)

    oracle中,如何将两个字段数据合并成一个字段显示,接下来看一下在sql server和pl/sql的区别 sql server中如何合并(用Cast()函数) --1.创建模拟的数据表--- cr ...

  7. 你搞懂 ORACLE、 SQLSERVER、MYSQL与DB2的区别了吗

    ORACLE. SQLSERVER.MYSQL与DB2的区别--平台性:    Oracle.MYSQL与DB2可在所有主流平台上运行:    SQL Server只能在Windows下运行: --安 ...

  8. NUll在oracle与sqlserver中使用相同与区别

    最近在使用Oracle进行开发,遇到很多与以前使用sqlserver的不同语法.今天遇到null在两种数据库上面操作上的差别,在此记录两种数据库上的差异. null 与字符串相加 1.在oracle中 ...

  9. CTE在Oracle和Sqlserver中使用的差异

    CTE是一个很好用的工具,他可以帮助我们清晰代码结构,减少临时表使用,同时oracle和sqlserver都提供支持.但在oracle和sqlserver中使用CTE也存在一定区别. Oracle使用 ...

随机推荐

  1. web页面之响应式布局

    一.什么是响应式布局? 响应式布局是Ethan Marcotte在2010年5月份提出的一个概念,简而言之,就是一个网站能够兼容多个终端——而不是为每个终端做一个特定的版本.这个概念是为解决移动互联网 ...

  2. 我们是怎么管理QQ群的

    文章背景:腾讯平台上的qq群数以千万百万计,但99%的在吹水扯蛋,从早上的问好开始,到晚上的晚安,无一不浪费青春之时间,看之痛心,无力改变,只好自己建了一个,希望能以此来改变群内交流的氛围或环境. 以 ...

  3. ASP.NET vNext on CentOS 7

    第一步是在Linux上安装.Net的运行时Mono VNext要求Mono最小版本3.4.1,可怜的centos连低版本的mono都不含.我们只能通过编译来安装.目前最新的版本为3.12 源码下载:h ...

  4. tips~function pointer

    An simple example: #include<stdio.h> int plus(int a,int b) { return a+b; } int main() { int (* ...

  5. 一张图告诉你,只会Node.JS还不够!

    一本nodejs代码段.

  6. 第3月第23天 EAIntroView

    1. EAIntroView,界面和模型分离.EAIntroPage数据模型,EAIntroView界面. https://github.com/ealeksandrov/EAIntroView

  7. php数组array_push()和array_pop()以及array_shift()函数

    <?php /** * array_push()将一个或多个单元压入数组的末尾(入栈) */ $stack = array("Java", "Php", ...

  8. Func

    Func<List<int>, string> getStr = (list) => { var returnStr = ""; if (list.A ...

  9. I18n问题 国际化

    http://www.cnblogs.com/guaniu/archive/2012/01/18/2325556.html java国际化 1.了解缺省Locale是由操作系统决定的,Locale是由 ...

  10. 耿丹CS16-2班助教总结

    Deadline: 2016-1-7 11:59pm 开篇有言 --又是一年末,不似风光,却添风霜,顶霾前进,踽踽独行,可乎? 助教那些事儿 助教这份工作是之前就担任过的,很羞愧,当时才担任了几天就撒 ...