Details

    Description

      Feature request - new option innodb_automatic_pk (default off, global/session)

      During CREATE TABLE for InnoDB, automatically translate

      -- FROM:

      CREATE TABLE t1 (c2 INT) ENGINE=InnoDB;

      -- TO:

      CREATE TABLE t1 (_inv_PK SERIAL INVISIBLE PRIMARY KEY, c2 INT) ENGINE=InnoDB;

      -- FROM:

      ALTER TABLE t1 ADD PRIMARY KEY (`c2`);

      -- TO:

      ALTER TABLE t1 DROP COLUMN IF EXISTS _inv_PK, ADD PRIMARY KEY (`c2`);

      It might be a good idea to modify or suppress warning "Can't DROP COLUMN `_inv_PK`" and to issue a warning that _inv_PK was created.

      Attachments

        Issue Links

          Activity

            danblack Daniel Black added a comment -

            This would really help app frameworks that aren't good at doing it all at once.

            danblack Daniel Black added a comment - This would really help app frameworks that aren't good at doing it all at once.
            marko Marko Mäkelä added a comment - MySQL 8.0.30 includes WL#13784 - Create auto_increment PK on table creation when no PK is specified .
            ib-mlatin Matthew Latin added a comment -

            This would definitely help quite a bit since there are a lot of frameworks that habitually do not use PKs. Having to modify apps to add dummy PKs is not very feasible sometimes.

            ib-mlatin Matthew Latin added a comment - This would definitely help quite a bit since there are a lot of frameworks that habitually do not use PKs. Having to modify apps to add dummy PKs is not very feasible sometimes.
            SylvainArbaudie Sylvain ARBAUDIE added a comment - - edited

            is it possible to have something lighter than auto increments ? they are actually quite heavy and cause issues with all replication systems

            coiuld we not use a regular hidden column, and auto create a sequence ? that would be easier to manage than auto increments.
            something like this :

            PK int default sequence.nextval() invisible key

            SylvainArbaudie Sylvain ARBAUDIE added a comment - - edited is it possible to have something lighter than auto increments ? they are actually quite heavy and cause issues with all replication systems coiuld we not use a regular hidden column, and auto create a sequence ? that would be easier to manage than auto increments. something like this : PK int default sequence.nextval() invisible key

            People

              Unassigned Unassigned
              mg MG
              Votes:
              4 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.