当前位置:网站首页>Oracle primary key auto increment
Oracle primary key auto increment
2022-07-02 15:22:00 【SherlockerSun】
Oracle The primary key increases automatically
1、 Build table
CREATE TABLE TEST_TABLE
(
ID INT NOT NULL,
NAME VARCHAR2(40) NULL,
AGE VARCHAR2(40) NULL
);
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
2、 Set primary key
ALTER TABLE TEST_TABLE ADD CONSTRAINT TEST_TABLE_PK PRIMARY KEY (ID);
- 1.
3、 New sequence
CREATE SEQUENCE TEST_TABLE_AUTOINC_SEQ
MINVALUE 1
NOMAXVALUE
INCREMENT BY 1
START WITH 1
NOCACHE;
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
4、 New trigger
CREATE OR REPLACE TRIGGER TEST_TABLE_AUTOINC_TG
BEFORE INSERT ON TEST_TABLE FOR EACH ROW
BEGIN
SELECT TEST_TABLE_AUTOINC_SEQ.NEXTVAL INTO:NEW.ID FROM DUAL;
END;
- 1.
- 2.
- 3.
- 4.
- 5.
5、 test
INSERT INTO TEST_TABLE (NAME,AGE)VALUES(' test 1','18');
INSERT INTO TEST_TABLE (NAME,AGE)VALUES(' test 2','19');
INSERT INTO TEST_TABLE (NAME,AGE)VALUES(' test 3','20');
- 1.
- 2.
- 3.
6、 result
SELECT * FROM TEST_TABLE;
- 1.
边栏推荐
- Introduction to C language -- array
- 做好抗“疫”之路的把关人——基于RK3568的红外热成像体温检测系统
- MFC timer usage
- IE 浏览器正式退休
- Solution of Queen n problem
- Common English abbreviations for data analysis (I)
- 16_ Redis_ Redis persistence
- Jenkins Pipeline 应用与实践
- vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)
- 10_Redis_geospatial_命令
猜你喜欢
Introduction to C language -- array
XML Configuration File
Have you learned the wrong usage of foreach
08_ strand
编译原理课程实践——实现一个初等函数运算语言的解释器或编译器
Learn the method code example of converting timestamp to uppercase date using PHP
FPGA - clock-03-clock management module (CMT) of internal structure of 7 Series FPGA
Mavn 搭建 Nexus 私服
你不知道的Set集合
. Net core logging system
随机推荐
vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)
Deploy tidb cluster with tiup
2021-2022学年编译原理考试重点[华侨大学]
二叉树的遍历方式主要有:先序遍历、中序遍历、后序遍历、层次遍历。先序、中序、后序其实指的是父节点被访问的次序。若在遍历过程中,父节点先于它的子节点被访问,就是先序遍历;
04_ 栈
Solve the problem that El radio group cannot be edited after echo
Huffman tree: (1) input each character and its weight (2) construct Huffman tree (3) carry out Huffman coding (4) find hc[i], and get the Huffman coding of each character
原则、语言、编译、解释
The past and present lives of visual page building tools
语义分割学习笔记(一)
學習使用php實現公曆農曆轉換的方法代碼
Kibana basic operation
How to conduct TPC-C test on tidb
面对“缺芯”挑战,飞凌如何为客户产能提供稳定强大的保障?
Mfc a dialog calls B dialog function and passes parameters
MFC CString to char*
CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E
Practical debugging skills
LeetCode_ Sliding window_ Medium_ 395. Longest substring with at least k repeated characters
Map introduction