Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7403525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:06:26+00:00 2026-05-29T05:06:26+00:00

I want to add a column to an existing Firebird database (version 2.5) and

  • 0

I want to add a column to an existing Firebird database (version 2.5) and write a procedure by which I can assign each record a different value. Something like add a column and autogenerate the data for it.

Like, if I add a new column called “ID” (number) I want then initialize a unique value to each of the records. So, my ID column will have records from say 1 to 500. How can I achieve this by using only sql script (i.e. without using some high-level programming language for generating sql commands)?

Basically what I need is something like identity columns in Firebird 3.0:

alter table MY_TABLE
add ID int identity(1,1)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:06:27+00:00Added an answer on May 29, 2026 at 5:06 am

    This columns will have a default value of 1:

    alter table MY_TABLE add ID int default 1 
    

    You can have an auto-incrementing PK using a generator and a BEFORE INSERT trigger:

    CREATE GENERATOR GEN_PK;
    COMMIT;
    
    
    CREATE TRIGGER GENERATE_PK FOR MY_TABLE
    ACTIVE BEFORE INSERT
    AS
    BEGIN
      IF(NEW.ID IS NULL) THEN 
        NEW.ID = GEN_ID(GEN_PK, 1);
    END
    

    I didn’t understand when you need the random data you said, though.

    note that they are two different examples, they are not to be used on together on the same column

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a column to an existing legacy database and write a
I want to add a column to a gridview which contains button control. I
I want to add a button to each row of a column of an
I want to add a new column to a table which already consists billions
I have a table that I want to add a bit column, which I
I want to add a column to an existing model, and after running schemamigration
I want to add a record into access. The column name is Names: Now
I don't think I can actually add a field (column) to an existing IEnumerable.
I want to add a new column to an existing mysql table, where the
i can't add 2 column in my existing db. i read any topic on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.