I was supposed to migrate data from SQL Server to ORACLE. I did not expect that after the migration, the program would go wrong and cannot insert NULL. It is easy to think that the ID auto-increment mechanism of the two is different, problems may occur during direct migration. In SQLSERVER, it is very easy to add fields. You can identify the auto-increment on the lower point. But it is not that simple in ORACLE,
I was supposed to migrate data from SQL Server to ORACLE. I did not expect that after the migration, the program would go wrong and cannot insert NULL. It is easy to think that the ID auto-increment mechanism of the two is different, problems may occur during direct migration. In SQLSERVER, it is very easy to add fields. You can identify the auto-increment on the lower point. But it is not that simple in ORACLE,
I was supposed to migrate the data in SQL Server to ORACLE. I did not expect that after the migration, the program would fail to insert a NULL value, it is easy to think that because the ID auto-increment mechanism of the two is different, direct migration will cause problems. In SQLSERVER, it is very easy to add fields. You can identify the auto-increment on the lower point. However, it is not that simple in ORACLE, and you have not figured out why, ORACLE should divide the frequently used auto-increment fieldsSEQUENCE)AndTRIGGER)If you know the details and benefits, please do not give me some advice.
Because my table already exists, we only need to create the sequence and trigger in the two steps described above.
1. Create a sequence
Create sequence sq_logINCREMENT BY 1 -- add a few start with 700 each time -- the migrated data has recorded MINVALUE 1 -- Minimum value 1 NOMAXVALUE -- do not set the maximum value NOCYCLE -- always accumulate, non-circular NOCACHE-no buffer Creation
2. Create a trigger
CREATE TRIGGER tri_log BEFORE INSERT ON DBLOG FOR EACH ROW BEGIN SELECT sq_log.nextval into :new.logid from dual; END tri_log;