惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
H
Help Net Security
Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
L
LINUX DO - 最新话题
A
Arctic Wolf
博客园_首页
S
Securelist
S
Secure Thoughts
Google DeepMind News
Google DeepMind News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
N
Netflix TechBlog - Medium
Cyberwarzone
Cyberwarzone
小众软件
小众软件
T
Threatpost
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Blog — PlanetScale
Blog — PlanetScale
N
News and Events Feed by Topic
NISL@THU
NISL@THU
Forbes - Security
Forbes - Security
博客园 - 聂微东
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
H
Heimdal Security Blog
罗磊的独立博客
S
Security @ Cisco Blogs
B
Blog
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
Hacker News - Newest:
Hacker News - Newest: "LLM"
I
Intezer
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
The Cloudflare Blog
S
Schneier on Security
月光博客
月光博客
L
LINUX DO - 热门话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - IT爱好者

C# 自定义打印 C# 打印,不显示打印进度对话框 如何解决迅雷插件导致IE10崩溃的问题 ASP.NET MVC 使用Jquery Uploadify 在非IE浏览器下Http Error的解决方案 c#操作access,update语句不执行的解决办法 解决:System.Data.SqlClient.SqlError: FILESTREAM 功能被禁用 服务器“**”上的MSDTC不可用的解决办法 通过Package Manager Console 向VS2010安装 EFCodeFirst 删除SVN遗留的无用文件 解决"System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本" 修改IIS默认的localhost名称 IIS服务器应用程序不可用的解决办法 使用XML与远程服务器进行交互 小米手机指令大全 Java与.NET DES加密解密互转 获取执行SQL语句的返回结果 ASP.NET中如何向页面写入JavaScript脚本内容 ASP.net中用JSON序列化对象 android Listview 拖动时背景为黑色问题
Oracle自增列创建方法
IT爱好者 · 2011-07-15 · via 博客园 - IT爱好者

最近在做Oracle的项目,由于以前没有接触过Oracle的开发,遇到了不少的问题,比如给Oracle表添加自增列,与SQL Server就不同。

Oracle没有自增字段这样的功能,但是通过触发器(trigger)和序列(sequence)可以实现。

先建一个测试表了:

create table userlogin
(

     id   number(6) not null,

     name   varchar2(30)   not null primary key

)

tablespace users

/

第一步:创建SEQUENCE


create sequence userlogin_seq increment by 1 start with 1 minvalue 1 maxvalue 9999999999999 nocache order;


第二步:创建一个基于该表的before insert 触发器,在触发器中使用刚创建的SEQUENCE


create or replace trigger userlogin_trigger
before insert on userlogin
for each row
begin
      select   userlogin_seq.nextval   into:new.id from sys.dual ;
end;

/

第三步:在userlogin表中测试

写个insert语句,插入一条记录,看ID字段自增了没,自增则OK啦。