Forum > Database

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

<< < (2/2)

devEric69:
For info., found on Firebird's site: https://www.firebirdsql.org/file/documentation/release_notes/html/en/3_0/rlsnotes30.html#rnfb30-ddl-identity .

devEric69:
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.

devEric69:
Well, finally, it works very well with Firebird's native auto-incremented fields. The DDL syntax has no parenthesis ( https://github.com/FirebirdSQL/firebird/issues/6906 ). 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;

egsuh:

--- 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.

Navigation

[0] Message Index

[*] Previous page

Go to full version