The steps for creating columns in Oracle automatically grow as follows:
1 Create a table first, such as: Create TABLE "DEPARTMENT"
("department_id" number,
"Department_name" VARCHAR2 not NULL ENABLE,
"MANAGER_ID" number (6, 0),
"LOCATION_ID" number (4, 0),
PRIMARY KEY ("department_id") ENABLE
)
/
2 Creating a sequence for the department_id column: Create SEQUENCE "Department_seq" MinValue 1 MAXVALUE 9999 INCREMENT by 1 START with 1 NoCache noorder nocycle
3 Create a trigger for this table: Create OR REPLACE TRIGGER "Insert_department"
Before
Insert on "DEPARTMENT"
For each row
Begin
Select "Department_seq". Nextval into:new. DEPARTMENT_ID from dual;
End;
/
ALTER TRIGGER "Insert_department" ENABLE
/
4 over, then if you need to insert data into the table, the department_id can grow automatically. The column minimum value is 1, the maximum is 9999, and the cardinality is 1, which you can modify according to your own needs.
5 Oracle Another way to achieve automatic growth is as follows (still, for example, the table built above):
First create sequence: Drop sequence department_seq;
Create sequence Department_seq
Increment by 1
Start with 1
MaxValue 9999999999
NoCache;
You can then write the INSERT statement directly, as follows: Insert into department values (Department_seq.nextval, ' R & D ', 8, 10); This shows that the way to complete a function is varied, frankly, I do not know whether the two methods are good or bad, but I am more inclined to use the first method.