zoukankan      html  css  js  c++  java
  • SQL SERVER VS ORCALE(实现已有数据行自增)

    如果数据库中已经存在大量数据,那么如何才能实现自增字段呢?

    • 先说SQL SERVER(据可靠消息,大约十年前这句话卖了70万RMB):
    DECLARE @i INT
    SET @i = 0

    UPDATE table_name
    SET @i = @i + 1 ,--重点在这里
    id = @i

    • 再说ORCALE(用游标是实现)
    declare cursor c_cursor is
    select uslogin from userinfo where userinfoid is null for update;
    --uslogin:登陆账号是唯一的

    vr_login c_cursor
    %RowType;
    vr_i
    number:=1;

    begin
    open c_cursor;

    loop
    fetch c_cursor into vr_login;
    exit when c_cursor%notfound;

    --逐一更新
    update userinfo set userinfoid = vr_i where uslogin = vr_login.uslogin;

    vr_i :
    = vr_i + 1;
    end loop;

    close c_cursor;
    end ;
  • 相关阅读:
    linux笔记
    ui转化为py
    stl学习
    React第一课
    React 第一课
    创建一个类
    nodejs基本语法
    let和const
    qml_status笔记
    controller层的单元测试
  • 原文地址:https://www.cnblogs.com/BingoLee/p/2092008.html
Copyright © 2011-2022 走看看