Forum > Database

[Solved] Firebird 3 \ IBX : how to restart native auto-incremented IDs fields?

<< < (2/2)

For info., found on Firebird's site: .

nevertheless, this DDL statement ( "ALTER TABLE ... ALTER COLUMN ... (RESTART WITH <n>);" ) does nothing on the native IDentity fields, without external SQL generator. I will create an issue \ bug report at Firebird's gitHub, to see \ ask if this is normal.

Well, finally, it works very well with Firebird's native auto-incremented fields. The DDL syntax has no parenthesis ( ). For example, if there are only 3 records left in a very emptied table, and i want the next num#-ID to be 4 (more seriously, this can be useful to reset things at the beginning of the year, for example, like resetting the ID-counter of an INVOICES table to 1, ...):

--- Code: MySQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ALTER TABLE MY_TABLE ALTER COLUMN MY_IDENTITY_COLUMN_ID RESTART WITH 3;


--- Quote --- export everything (DDL + data) in SQL script, change the keys manually and recreate the database via the script.
--- End quote ---

I thought creating database first with DDL without data, and insert data without the key field. Will this work? It's not easy to move data from one database to another anyway.


[0] Message Index

[*] Previous page

Go to full version