zoukankan      html  css  js  c++  java
  • Oracle 数据库与 MSSQL 语言比较

    Oracle MS sql
    赋值 select col1 into v_name from employee select @name= name from employee
    申明 Declare v_user varchar2; Declare @user varchar(200);
    用现有表创建表 create table newTable as select * from oldTable; select * into newTable from oldTable
    选择前N行

    select *  from (select * from table order by Id) a where rownum<=N;

    select top N * from table
    自动增加Id



    create trigger on table
    before insert
    for each row
    is
    begin
    select squence.nextval into v_newId from dual;
    :new.Id := v_newId;
    end;

    需要建立一个序列

    设置一个列为自动增长即可
    连接表更新

    update table1 a set a.col1 = (select col2 from table2 b where a.col1= b.col2);

    update a set a.col1 =b.col2
    from table1 a join table2 b
    on a.cola = b.colb

    使用游标

    declare v_name varchar2(20);
    cursor myCursor is select name from employee;
    begin
    open myCursor;
    loop
    fetch myCursor into v_name;
    --do somethings;
    exit when myCursor%NotFound;
    end loop;
    close myCursor;


  • 相关阅读:
    Linux下的邮件发送
    Linux下用户和raid练习题
    Linux centos7.5操作系统的安装
    Linux chattr文件锁
    Linux系统下root密码丢失解决方案
    周总结2
    课堂作业1
    开课博客
    阅读3
    作业8
  • 原文地址:https://www.cnblogs.com/king_astar/p/724376.html
Copyright © 2011-2022 走看看