当前位置:网站首页>Oracle primary key auto increment setting
Oracle primary key auto increment setting
2022-07-24 20:27:00 【Yu Lei [xingshuo century]】
-- Create table
CREATE TABLE tb_demo
(
id INT NOT NULL,
key1 VARCHAR2(40) NULL,
key2 VARCHAR2(40) NULL
);
-- Set primary key
alter table tb_demo add constraint tb_demo_pk primary key (id);
-- New sequence
create sequence tb_demo_id
minvalue 1
nomaxvalue
increment by 1
start with 1
nocache;
-- New trigger
create or replace trigger tb_demo_tg_insertId
before insert on tb_demo for each row
begin
select tb_demo_id.Nextval into:new.id from dual;
end;
-- insert data
insert into tb_demo (key1, key2)
values ('key1', 'key2');
insert into tb_demo (key1, key2)
values ('key11', 'key22');
-- Query table
select * from tb_demo;
-- Query the current sequence value
select tb_demo_id.currval from dual;
边栏推荐
- Substr and substring function usage in SQL
- TCP sliding window, singleton mode (lazy and hungry) double checked locking / double checked locking (DCL)
- C# 窗体应用TreeView控件使用
- How to set the allure test report
- Lunch break train & problem thinking: on multidimensional array statistics of the number of elements
- [training Day9] maze [line segment tree]
- [training Day8] [luogu_p6335] staza [tarjan]
- Lights of thousands of families in the year of xinchou
- Functional test of redisgraph multi active design scheme
- What is IDE (integrated development environment)
猜你喜欢
![[training Day10] point [enumeration] [bidirectional linked list]](/img/62/41dcab40eeb6aea545602e10c1c1a0.png)
[training Day10] point [enumeration] [bidirectional linked list]

Modbus communication protocol specification (Chinese) sharing

Alibaba sentinel basic operation
![[training Day8] series [matrix multiplication]](/img/00/06f7eb935bfd3c195e2e135197b4bd.png)
[training Day8] series [matrix multiplication]

Redis basic knowledge, application scenarios, cluster installation

How to set appium script startup parameters

从码农转型大音乐家,你只差这些音乐处理工具

YouTube "label products" pilot project launched

Upgrade appium automation framework to the latest 2.0

Machine learning job interview summary: five key points that resume should pay attention to
随机推荐
Fluoronisin peptide nucleic acid oligomer complex | regular active group alkyne, SH thiol alkynyl modified peptide nucleic acid
[Extension Program - cat scratch 1.0.15 _ online video and audio acquisition artifact _ installation tutorial plus acquisition]
[training Day10] point [enumeration] [bidirectional linked list]
Selenium is detected as a crawler. How to shield and bypass it
[training Day9] rotate [violence] [thinking]
Oracle 19C datagruad replication standby rman-05535 ora-01275
Do you want to verify and use the database in the interface test
Near infrared dye cy7.5 labeling PNA polypeptide experimental steps cy7.5-pna|188re labeling anti gene peptide nucleic acid (agpna)
Make Huawei router into FTP server (realize upload and download function)
1. Mx6u-alpha development board (key input experiment)
Substr and substring function usage in SQL
[training Day8] tent [mathematics] [DP]
Methods of using tyrosine modified peptide nucleic acid PNA | Tyr PNA | BZ Tyr PNA | 99Tcm survivinmrna antisense peptide nucleic acid
Istio II traffic hijacking process
Sql164 next day retention rate of new users per day in November 2021
Usage and introduction of MySQL binlog
Install MySQL 5.7.37 on windows10
Pychart tutorial: 5 very useful tips
Leetcode 1911. maximum subsequence alternating sum
Hcip early summary