- sql server
-
IF OBJECT_ID('Autotest.SA.CUSTOMER','U') is not null Drop table Autotest.SA.CUSTOMER; CREATE TABLE Autotest.SA.CUSTOMER ( customer_id int IDENTITY (1,1) PRIMARY KEY , c_custkey nVarChar(50) default '', c_mktsegment nVarChar(50) default '', c_privilege_level int );
- Use IDENTITY (m, n)
- m represents the initial value, n represents the value automatically increases every time
- Values of m and n is not specified, the default is (1,1)
-
- mysql
-
drop table if exists Autotest.CUSTOMER; CREATE TABLE autotest.CUSTOMER ( customer_id int auto_increment PRIMARY KEY, c_custkey nVarChar(50) default '', c_mktsegment nVarChar(50) default '', c_privilege_level int );
-
Use auto_increament
- Index must be specified, the above example defines the primary key index with PRIMARY KEY
- The default increment starting from 1
- Set the self-energizing start value n: alter table table_name AUTO_INCREMENT = n
-
- Oracle
- Establish increment sequence by sequence triggers +
- Create a table
-
create table SYSTEM.customer( id int not null PRIMARY KEY, column1 varchar(50) null, column2 varchar(50) null )
- Creating a Sequence
-
create sequence seq_perftest minvalue 1 maxvalue 99999999 start with 1 increment by 1 cache 50
drop sequence seq_perftestStarting value of 1, in increments of 1
- Creating Triggers
-
create or replace trigger "perfest_trig" before insert on SYSTEM.customer for each row begin select seq_perftest.nextval into :new.id from dual; end;
- Verify whether the entry into force increment insert into system.customer (column1, column2) values ( 'test1', 'test2')
- Batch production procedure stored data
-
create procedure system.pro_test( init in number, loop_time in number ) IS vars number; i INTEGER; begin vars := 0; i := init; while vars<loop_time loop insert into system.customer(column1,column2) values (('test'||i),('test'||i) i := i+1; vars := vars+1; end loop; commit; end pro_test;
exec system.pro_test (1,100000)
- Hana
- To create a custom sequence increase by
- Create a table
-
create table SYSTEM.customer( id int, column1 varchar(50) null, column2 varchar(50) null );
- Creating a Sequence
-
create sequence system.seq_perftest increment by 1 maxvalue 99999999 minvalue 1 NO CYCLE start with 1; drop sequence seq_perftest;
- Verify whether the entry into force increment insert into system.customer (id, column1) values (system.seq_perftest.nextval, 'test123')
- Using stored procedures to increase bulk data
-
create procedure system.pro_test( i INTEGER, loop_time INTEGER ) As begin For i in 1 .. loop_time DO insert into system.customer(id,column1,column2)values (system.seq_perftest.nextval,('test'||i),('test'||i); i := i+1; end FOR; end; call system.pro_test(1, 100000)