Altering an IDENTITY Column
參考:Oracle 如何做到 SQL Server 的 Identity 欄位型態 - Yowko's Notes
https://www.oracletutorial.com/oracle-basics/oracle-identity-column/
Oracle 12c introduced a new way that allows you to define an identity column for a table, which is similar to the AUTO_INCREMENT column in MySQL or IDENTITY column in SQL Server.
**Oracle原本無identity用法
--1. 先移除原本存在的IDENTITY
ALTER TABLE test_tb (MODIFY pk_id DROP IDENTITY);
--2. 指定sequence給pk_id
alter table test_tb modify pk_id default on null test_tb_seq .nextval;
-- CREATE SEQUENCE
CREATE SEQUENCE test_tb_seq
START WITH 1
INCREMENT BY 1
MAXVALUE 9999999999999999999999999999
CACHE 20
CYCLE
沒有留言:
張貼留言