当前位置:网站首页>How to set primary key self growth in PostgreSQL database
How to set primary key self growth in PostgreSQL database
2022-07-19 06:59:00 【He is a rookie programmer】
For the first time today postgresql database , Find it and mysql Is not the same , You cannot set the primary key with a view id Self growth , Therefore, you can add a sequence to the primary key , In this way, we can achieve self growth !
following , Is to add serialization and set serialization to id above sql sentence :
CREATE SEQUENCE "employee_management_emp_seq" // Set sequence name
INCREMENT 1 // Growth value
MINVALUE 1 // minimum value
MAXVALUE 999 // Maximum
START 1 // Initial value
CACHE 1; // cache The above values correspond to this figure , You can also add a sequence directly here
Click other , Then select the sequence

The last step is to set the newly added sequence to the primary key
alter table Table name alter column Primary key field name set default nextval('employee_management_emp_seq'( The sequence name just added ))It's done here ! At this time, just go back and look at your watch , You will find that the default constraints under the fields of the primary key are from NULL It's a sequence , Here's the picture :

边栏推荐
- 使用Altium Designer软件绘制一个基于stm32设计
- What happened to redraiment
- Tower of Hanoi 2 (function)
- Personal information management system
- Wireshark packet capture: message information
- 高并发day04(ZAB协议,观察者,nc,AVRO,RPC)
- Application case of CS brand sdnand in color detector industry
- day01(Flume)
- Common user password encryption methods and cracking methods
- C language structure array pointer and function
猜你喜欢
![[CS Genesis] comparative analysis of advantages and disadvantages of SD NAND and raw NAND](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[CS Genesis] comparative analysis of advantages and disadvantages of SD NAND and raw NAND

Generate audio and waveform in PWM and DAC exercises of stm32

数据保护/磁盘列阵RAID保护 IP段103.103.188.xxx

Application case of CS brand sdnand in color detector industry

企业或个人域名备案怎么弄

内网穿透服务器搭建教程,NPS使用教程

day01(Flume)
![[automated testing] - robotframework practice (I) building environment](/img/3e/4aa4ef8e64efa81bb168ab5aff666e.png)
[automated testing] - robotframework practice (I) building environment

小迪网络安全-笔记(5)

STM32 serial communication related learning
随机推荐
What happened to redraiment
寄居蟹和海葵
轻重搭配(贪心)
传奇手游怎么开服?需要投资多少?需要那些东西?
Learning about STM assembler design
阿里云、腾讯云、华为云、Ucloud(优刻得)、天翼云 的云服务器性能测试和价格对比
高并发day02(Concurrent包)
Xiaodi network security notes - Information Collection - architecture, construction, WAF (8)
Zuul路由的映射规则配置
Freebsd 12 安装RPM包
关于文件上传下载问题
Thales安全解决方案:怎么提高国家网络安全的关键步骤
Performance evaluation and comparison of Huawei cloud Kunpeng arm ECs and x86 ECS
University
Release nohup Out disk space occupied
Minecraft Paper 1.18.1 版开服教程,我的世界开服教程,MCSManager9面板使用教程
STM32 serial communication related learning
SSH remote login service
Double code time scale network diagram
Arm server building my world (MC) version 1.18.2 private server tutorial