Sequences, triggers, and other related uses
SQL Server under Microsoft grows as long as the set column identity
Create Table intIdentity(1,1primarykey not Nullvarchar();
MySQL to achieve self-growth as long as the set column auto_increment
Create Table intprimarykeynotnullvarchar (15 ));
The Oracle database is a bit different, and does not have a self-growing column type like MySQL and SQL Server databases, but rather a sequence for uniqueness and self-growth.
Create Table Employee ( number, varchar2(+), VARCHAR2(max) publishdate date, number, Constraintprimarykey(PID) );
Sequence:
Create sequence Publish_autoinc 1 9999999999999999999999999999with 1 by 1 NoCache;
Once you have defined the publish_autoinc sequence, you can access the Curval and Nextval properties of the sequence.
curval: Returns the current value of the sequence
nextval: Increase the value of the sequence first, and then return the sequence value
INSERT INTO employee values (publish_autoincnextval, 'ptitle1 ', 'pcontent1 ', sysdate,1);
Using triggers:
Create or Replace Trigger insert_publish_autoinc Insert on Publish for Each row begin Select into from dual; End insert_publish_autoinc;
This automatically inserts the next value of the sequence into the PID whenever an insert operation is made to the Publish table, enabling self-growth.
END
Oracle's easy-to-use implementation is self-growing