当前位置:网站首页>PostgreSQL设置自增字段
PostgreSQL设置自增字段
2022-06-27 23:01:00 【code-x】
postgres 自增需要先进行创建自增序列, 指定自增值, 最小值, 最大值:
CREATE SEQUENCE "public"."tt_id_seq" INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;设置序列所有者:
ALTER TABLE "public"."tt_id_seq" OWNER TO "postgres";设置自增从1开始:
SELECT setval('"public"."tt_id_seq"', 1, false);自增字段添加默认建立连接:
nextval('tt_id_seq'::regclass)例
CREATE TABLE "public"."test" (
"id" int4 NOT NULL DEFAULT nextval('tt_id_seq'::regclass),
"name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL
PRIMARY KEY ("id")
)边栏推荐
猜你喜欢

Why stainless steel swivel

Summary of wuenda's machine learning course (14)_ Dimensionality reduction

深入解析kubernetes controller-runtime

Introduction to memory model of JVM

MATLB|改进的前推回代法求解低压配电网潮流

Why are cloud vendors targeting this KPI?

.mp4视频测试地址

Alchemy (1): identify prototype, demo and MVP in project development

Taro---day2---编译运行

Arduino uno realizes simple touch switch through direct detection of capacitance
随机推荐
logging日志的使用
Function and usage of malloc function in C language
吸顶方案1
完全二叉树的节点个数[非O(n)求法 -> 抽象二分]
攻击队攻击方式复盘总结
Taro--- day1--- construction project
Message Oriented Middleware for girlfriends
. Mp4 video test address
Logging log usage
Efficient supplier management in supply chain
无人机专用滑环定制要求是什么
快速掌握grep命令及正则表达式
Installation and use of Zotero document management tool
同花顺股票开户是会有什么风险吗?同花顺开户安全吗
#796 Div.2 F. Sanae and Giant Robot set *
Taro--- day2--- compile and run
Latest MySQL advanced SQL statement Encyclopedia
深入解析kubernetes controller-runtime
Huawei partners and Developers Conference 2022 | Kirin software cooperates with Huawei to jointly build the computing industry and create a digital intelligence future
The limits of Technology (11): interesting programming