Announcement

Collapse
No announcement yet.

How to create an auto increment in an existing table?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to create an auto increment in an existing table?

    I use:
    - Win 7x64
    - ms Sql Server 2012
    - Navicat 12.0.17 (64-bit) - Premium.

    I have a table.
    The table is not filled.

    Code:
    CREATE TABLE [dbo]. [Tbl_977_1_Test_AI_IDNTI] (
       [id_num] INT NOT NULL,
       [fname] VARCHAR (20) COLLATE Cyrillic_General_CI_AS DEFAULT NULL NULL,
       [minit] CHAR (1) COLLATE Cyrillic_General_CI_AS DEFAULT NULL NULL,
       [lname] VARCHAR (30) COLLATE Cyrillic_General_CI_AS DEFAULT NULL NULL,
       CONSTRAINT [PK_tbl_977_1_Test_AI_IDNTI] PRIMARY KEY CLUSTERED ([id_num])
    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
    ON [PRIMARY]
    )
    ON [PRIMARY]
    GO
    
    ALTER TABLE [dbo]. [Tbl_977_1_Test_AI_IDNTI] SET (LOCK_ESCALATION = TABLE)
    GO
    
    CREATE UNIQUE NONCLUSTERED INDEX [Primary_key]
    ON [dbo]. [Tbl_977_1_Test_AI_IDNTI] (
       [id_num] ASC
    )
    Question.
    How to set autoincrement for a field using "Navicat"?

  • #2
    Hi ivclim,

    To create an identity field, please follow the steps below:

    1. Open a table designer.
    2. Select the Options tab, choose the INT field in the Identity Field drop-down list.
    3. Set the Identity Seed, Identity Increment, Current Identity Value options if necessary.
    4. Save the settings.

    Comment


    • #3
      Originally posted by mayho View Post
      Hi ivclim,

      To create an identity field, please follow the steps below:

      1. Open a table designer.
      2. Select the Options tab, choose the INT field in the Identity Field drop-down list.
      3. Set the Identity Seed, Identity Increment, Current Identity Value options if necessary.
      4. Save the settings.
      How to activate the field "Identity Field"?

      Comment


      • #4
        Please note that if you want to add an identity field to an existing table, you need to add a new field and set it in the Options tab. For SQL Server, existing fields cannot set as identity field.

        1. Open a table designer.
        2. Add an int, decimal or numeric field in the Fields tab.
        3. Select the Options tab, choose the new field in the Identity Field drop-down list.
        4. Set the Identity Seed, Identity Increment, Current Identity Value options if necessary.
        5. Save the settings.

        Comment


        • #5
          Originally posted by mayho View Post
          Please note that if you want to add an identity field to an existing table, you need to add a new field and set it in the Options tab. For SQL Server, existing fields cannot set as identity field.

          1. Open a table designer.
          2. Add an int, decimal or numeric field in the Fields tab.
          3. Select the Options tab, choose the new field in the Identity Field drop-down list.
          4. Set the Identity Seed, Identity Increment, Current Identity Value options if necessary.
          5. Save the settings.
          Am I doing everything right?
          See the picture.

          Comment


          • #6
            Please upgrade your Navicat Premium to latest version (choose Help > Check for Updates) and follow the steps below again:

            1. Open a table designer.
            2. Add an int, decimal or numeric field in the Fields tab.
            3. Select the Options tab, choose the new field in the Identity Field drop-down list.
            4. Set the Identity Seed, Identity Increment, Current Identity Value options if necessary.
            5. Save the settings.

            Comment

            Working...
            X