We have learnt about the UNIQUE and Primary Key values for the columns in our previous blogs.
SQL Server Not Null Constraint in the table
SQL Server Primary Key Constraint in the table
The Primary Key which is a UNIQUE field value needs to be inserted every time when a record is inserted into the SQL Server table. To initiate the value to be generated automatically , we make the use of AUTO INCREMENT feature provided by SQL Server.
SQL Server Auto Increment Default value . The Automatic generation number will start with the value of 1 with the increment of 1 every time whenever a record is inserted.
CREATE TABLE oracleappshelpUsers ( UserId INT NOT NULL IDENTITY PRIMARY KEY, GivenName VARCHAR(128) NOT NULL, MiddelName VARCHAR(10) , FamilyName VARCHAR(128) NOT NULL, Age INT CHECK (Age>=18), Status VARCHAR(20) NOT NULL DEFAULT 'NEW' )
SQL Server Auto Increment can be provided with the custom value for start of specified Sequence value and Increment value . The Automatic generation number will start with the value of 1000 with the increment of 1 every time whenever a record is inserted.
CREATE TABLE oracleappshelpUsers ( UserId INT NOT NULL IDENTITY(1000,1) PRIMARY KEY, GivenName VARCHAR(128) NOT NULL, MiddelName VARCHAR(10) , FamilyName VARCHAR(128) NOT NULL, Age INT CHECK (Age>=18), Status VARCHAR(20) NOT NULL DEFAULT 'NEW' )