sql - How to create a unique id for each insert in Oracle
问题描述
I would like to have a unique ID for each INSERT. All rows for each INSERT must have the same ID, but different to the other IDs in the table. Is any standard way to do that in ORACLE?
解决方案
您可以在 Oracle 中使用序列:
CREATE SEQUENCE my_sq START WITH 1 INCREMENT BY 1;
然后,当您要插入时,请使用 my_seq.NEXTVAL 代替“按插入 ID”
有关序列的更多信息
推荐阅读
- java - servlet [dispatcherServlet] 的 Servlet.service() 在路径 [] 的上下文中引发异常 [过滤器执行引发异常],根本原因
- glsl - 每个顶点ID而不是顶点索引?
- tensorflow - 如何将多个 DNN 连接到另一个 DNN 的输入?
- django - Django DRF:read_only_fields 无法正常工作
- postgresql - 如何在 postgres pgAdmin 4 中查找和删除现有数据库
- machine-learning - Spacy-Transformers:访问 GPT-2?
- sql - 如果我对简单的选择查询执行回滚语句会发生什么
- excel - 从下拉列表中选择工作表并打印为 PDF
- python - 使用python在scattermapbox中的点周围绘制一个多边形
- python - 如何处理多个数据集的批量标准化?