Total Page Preview: 000000005297
What is Auto increment in SQL in English and Hindi
SQL auto increment in Engilsh
SQL autoincrement is a feature in database management systems that automatically generates a unique numerical value for a column when a new record is inserted into a table. This is typically used for primary key columns to ensure that each row in the table has a unique identifier.
Here's an example of how to use the autoincrement feature in SQL:
Suppose we have a table named "employees" with the following columns:
-
id (primary key)
-
name
-
age
-
salary
To make the "id" column an autoincrement column, we can use the "AUTO_INCREMENT" keyword when creating the table:
Now, when we insert a new record into the "employees" table without specifying a value for the "id" column, the database system will automatically generate a new unique value for us:
The resulting row in the "employees" table might look something like this:
The "id" column has been automatically assigned the value "1" because it is the first record in the table. If we were to insert another record without specifying an "id" value, the "id" column would be assigned the value "2", and so on.
SQL auto increment in Hindi
"Auto increment" ek SQL feature hai, jo kisi table ke column ko automatically increment karta hai, jab naye records insert kiye jaate hai. Is feature ka use mostly primary key column ke liye kiya jata hai, jisse har naya record unique identifier (ID) ke roop me pehchaan sakta hai.
SQL mei, AUTO_INCREMENT attribute ka use kiya jata hai, jo numeric data type ke columns ke liye hi apply kiya ja sakta hai. Ye attribute MySQL, SQL Server, Oracle, aur PostgreSQL jaisi popular database management systems mei available hai.
Example ke liye, hum ek "students" table ko consider kar sakte hai, jisme ek auto-increment primary key column "student_id" hai.
Is table ke saath, har naya record ke "student_id" column ki value apne aap increment hogi, jis se har record ka unique identifier banega. Is tarah, jab hum naye records ko insert karenge, to "student_id" column ko explicitly set karne ki zarurat nahi hogi:
Is code se, humne students table mei 3 naye records insert kiye hai, jisme "student_id" column ke values automatically increment hue honge.Is code se, humne students table mei 3 naye records insert kiye hai, jisme "student_id" column ke values automatically increment hue honge.
Thank You
About Author
Brijesh Kumar
Database Developer
I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL
Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall
and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com