0

I am running below SQL.

INSERT INTO project (project_id, works_no, project_name, project_location, project_owner, head_contractor, site_project_manager, project_manager_phone, created_time, created_by, company_id, lmd, project_status)
SELECT NULL AS project_id, works_no, project_name, project_location, project_owner, head_contractor, site_project_manager, project_manager_phone, '2020-10-16', '100', '3', '$2020-10-16', 'A'
FROM sample_project;

However when I check the database it seems like the auto increment order is missing. If I have more records in the source table the auto increment gap also getting increased.

enter image description here

Is there any reason for this. Still I couldn't find any reference.

James Z
  • 12,209
  • 10
  • 24
  • 44
Prasad Rajapaksha
  • 6,118
  • 10
  • 36
  • 52
  • 3
    It's perfectly normal. Don't worry about the gaps. (Although this would be less likely if you were using the InnoDB engine instead of MyISAM) – Strawberry Oct 16 '20 at 07:02
  • 2
    There is absolutely no guarantee that an `auto_increment` column would not have gap. It is guaranteed to be *unique*. See, for example: https://stackoverflow.com/questions/16582704/auto-increment-primary-leaving-gaps-in-counting – GMB Oct 16 '20 at 07:55

0 Answers0