MySQL: inconsistency in automatically increasing id

I wonder if you come across this that the numbers of the auto-increment identifiers are not ordered in the correct order , when you click the browse button on phpMyAdmin - is it just me? Something I set incorrectly in the db table?

For example, when you insert a series of data into a table, and you also deleted some of them, so when you check this table for phpMyAdmin, this data should appear in that order,

id

2
24
28
296
300

but in most of my tables they do not appear in order, instead they appear something like this:

id

24
300    
2
296    
28

as in this picture below

alt text

Can we do something so that the identifiers appear in the correct order?

EDIT 1:

, , . , "" phpMyAdmin, , SQL- order by.

?

alt text

2:

- , ?

CREATE TABLE IF NOT EXISTS `root_pages` (
  `pg_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `pg_url` varchar(255) DEFAULT NULL,
  `pg_title` varchar(255) DEFAULT NULL,
  `pg_subtitle` varchar(255) DEFAULT NULL,
  `pg_description` text,
  `pg_introduction` text,
  `pg_content_1` text,
  `pg_content_2` text,
  `pg_content_3` text,
  `pg_content_4` text,
  `pg_order` varchar(255) DEFAULT NULL,
  `pg_hide` varchar(255) DEFAULT '0',
  `pg_highlight` varchar(255) DEFAULT '0',
  `pg_important` varchar(255) DEFAULT '0',
  `pg_parent` varchar(255) DEFAULT '0',
  `parent_id` varchar(255) DEFAULT NULL,
  `pg_cat_id` varchar(255) DEFAULT NULL COMMENT 'page category id',
  `ps_cat_id` varchar(255) DEFAULT NULL COMMENT 'post category id',
  `tmp_id` varchar(255) DEFAULT NULL COMMENT 'template id',
  `pg_backdate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `pg_created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `pg_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`pg_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+3
3

, , PK INT? - VARCHAR TEXT, , . , - ? SHOW CREATE TABLE , .

. - MYISAM PK InnoDB, . MySql. , ORDER BY select.

+1

, : ORDER BY id ASC.

.

+7

, , order by .

SQL, , select, , , .

, , . , , , .

+2

Source: https://habr.com/ru/post/1787145/


All Articles