sql server - Using IDENTITY while creating table -


i learning sql , totally new world. have learnt / read using identity is: used create identity column seed , increment value ~ identity (seed, increment). going through sample database available on net, came across table creation script:

create table customer  (     id                   int                  identity,     firstname            nvarchar(40)         not null,     lastname             nvarchar(40)         not null,     city                 nvarchar(40)         null,     country              nvarchar(40)         null,     phone                nvarchar(20)         null,     constraint pk_customer primary key (id) ) go 

i tried creating table code , successful.

can explain why identity here not have seed , increment values? when should use (without seed , increment values) ?

tia

when use --> id int identity

it equivalent ---> id int identity(1,1)

so first value inserted table id = 1 , incremented 1 next row. default value identity if nothing specified. in case if want start id specific number, ex - want create customerid column should have @ least 5 digit id have define column ---> customerid int identity(10000 ,1)


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -