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 ;
  • 相关阅读:
    File操作
    集合
    几个python资料地址
    Case1-用list写shoppingcart
    字符串操作
    运算-Dictionary
    运算-list
    Python数据类型
    标准库和库导入
    Pycharm
  • 原文地址:https://www.cnblogs.com/BingoLee/p/2092008.html
Copyright © 2011-2022 走看看