Discussion:
[firebird-support] reset autoincrement field
Nico Speleers - Carfac BVBA nico.speleers@carfac.com [firebird-support]
2016-12-02 15:13:20 UTC
Permalink
How can I reset an autoincrement field in firebird 3 ? I used identity to make an autoincrement field.

Thanks.

Nico Speleers
Analyst





Carfac bvba

Driving on experience


Rijksweg 53
9680 Maarkedal
Tel. +32 55 23 00 00
Fax +32 55 31 00 95
***@carfac.com
www.carfac.be<http://www.carfac.be/>
[cid:***@01D11613.C23F19C0]<Loading Image...@01D11613.C23F19C0]<http://www.linkedin.com/company/hdc-software-nv> [cid:***@01D11613.C23F19C0] <https://twitter.com/carfacbvba>

[Beschrijving: Beschrijving: Beschrijving: CarfacAS (klein)]<http://www.carfac.be/>





[Non-text portions of this message have been removed]
'Zoran' zoran565@gmail.com [firebird-support]
2016-12-02 15:34:20 UTC
Permalink
To see current generator value



select gen_id(generator-name, 0) from rdb$database



To set generator value



set generator generator-name to value;







From: firebird-***@yahoogroups.com
[mailto:firebird-***@yahoogroups.com]
Sent: Friday, December 2, 2016 10:13 AM
To: firebird-***@yahoogroups.com
Subject: [firebird-support] reset autoincrement field





How can I reset an autoincrement field in firebird 3 ? I used identity to
make an autoincrement field.

Thanks.

Nico Speleers
Analyst

Carfac bvba

Driving on experience

Rijksweg 53
9680 Maarkedal
Tel. +32 55 23 00 00
Fax +32 55 31 00 95
***@carfac.com <mailto:***@carfac.com>
www.carfac.be <http://www.carfac.be%3chttp:/www.carfac.be/>
<http://www.carfac.be/>
[cid:***@01D11613.C23F19C0]<http://www.facebook.com/groups/12070918
1286476/>[cid:***@01D11613.C23F19C0]<http://www.linkedin.com/compan
y/hdc-software-nv> [cid:***@01D11613.C23F19C0]
<https://twitter.com/carfacbvba>

[Beschrijving: Beschrijving: Beschrijving: CarfacAS
(klein)]<http://www.carfac.be/>

[Non-text portions of this message have been removed]
Nico Speleers - Carfac BVBA nico.speleers@carfac.com [firebird-support]
2016-12-02 15:37:26 UTC
Permalink
I only use the property Identity to make an autoincrement field and I don't make use of generators. Therefore 'How can I reset an autoincrement field in firebird 3 ? I used identity to make an autoincrement field' ?

Nico Speleers
Analyst





Carfac bvba

Driving on experience


Rijksweg 53
9680 Maarkedal
Tel. +32 55 23 00 00
Fax +32 55 31 00 95
***@carfac.com
www.carfac.be<http://www.carfac.be/>
[cid:***@01D11613.C23F19C0]<http://www.facebook.com/groups/120709181286476/>[cid:***@01D11613.C23F19C0]<http://www.linkedin.com/company/hdc-software-nv> [cid:***@01D11613.C23F19C0] <https://twitter.com/carfacbvba>

[Beschrijving: Beschrijving: Beschrijving: CarfacAS (klein)]<http://www.carfac.be/>



Van: firebird-***@yahoogroups.com [mailto:firebird-***@yahoogroups.com]
Verzonden: vrijdag 2 december 2016 16:34
Aan: firebird-***@yahoogroups.com
Onderwerp: RE: [firebird-support] reset autoincrement field


To see current generator value

select gen_id(generator-name, 0) from rdb$database

To set generator value

set generator generator-name to value;



From: firebird-***@yahoogroups.com<mailto:firebird-***@yahoogroups.com> [mailto:firebird-***@yahoogroups.com]
Sent: Friday, December 2, 2016 10:13 AM
To: firebird-***@yahoogroups.com<mailto:firebird-***@yahoogroups.com>
Subject: [firebird-support] reset autoincrement field



How can I reset an autoincrement field in firebird 3 ? I used identity to make an autoincrement field.

Thanks.

Nico Speleers
Analyst

Carfac bvba

Driving on experience

Rijksweg 53
9680 Maarkedal
Tel. +32 55 23 00 00
Fax +32 55 31 00 95
***@carfac.com<mailto:***@carfac.com>
www.carfac.be<http://www.carfac.be/<http://www.carfac.be%3chttp:/www.carfac.be/>>
[cid:***@01D11613.C23F19C0]<http://www.facebook.com/groups/120709181286476/>[cid:***@01D11613.C23F19C0]<http://www.linkedin.com/company/hdc-software-nv> [cid:***@01D11613.C23F19C0] <https://twitter.com/carfacbvba>

[Beschrijving: Beschrijving: Beschrijving: CarfacAS (klein)]<http://www.carfac.be/>

[Non-text portions of this message have been removed]



[Non-text portions of this message have been removed]
'Zoran' zoran565@gmail.com [firebird-support]
2016-12-02 15:47:18 UTC
Permalink
IDENTITY in FB3 uses the same logic as previous versions (trigger and
generator), only it is hidden from the user. Behind the scenes it is doing
that.



If you don't find the better solution, here is how you can get generator
name for the Primary Key (IDENTITY):

(change CUSTOMER to your table name)



SELECT g.RDB$GENERATOR_NAME

FROM RDB$RELATION_FIELDS AS g

WHERE g.RDB$RELATION_NAME = 'CUSTOMER'

AND g.RDB$FIELD_NAME = (SELECT f.rdb$field_name

FROM rdb$index_segments AS f

LEFT JOIN rdb$relation_constraints AS rc ON
(rc.rdb$index_name = f.rdb$index_name)

WHERE rc.rdb$relation_name = 'CUSTOMER'

AND rc.rdb$constraint_type = 'PRIMARY KEY')









From: firebird-***@yahoogroups.com
[mailto:firebird-***@yahoogroups.com]
Sent: Friday, December 2, 2016 10:37 AM
To: firebird-***@yahoogroups.com
Subject: RE: [firebird-support] reset autoincrement field





I only use the property Identity to make an autoincrement field and I don't
make use of generators. Therefore 'How can I reset an autoincrement field in
firebird 3 ? I used identity to make an autoincrement field' ?

Nico Speleers
Analyst

Carfac bvba

Driving on experience

Rijksweg 53
9680 Maarkedal
Tel. +32 55 23 00 00
Fax +32 55 31 00 95
***@carfac.com
www.carfac.be<http://www.carfac.be/>
[cid:***@01D11613.C23F19C0]<http://www.facebook.com/groups/12070918
1286476/>[cid:***@01D11613.C23F19C0]<http://www.linkedin.com/compan
y/hdc-software-nv> [cid:***@01D11613.C23F19C0]
<https://twitter.com/carfacbvba>

[Beschrijving: Beschrijving: Beschrijving: CarfacAS
(klein)]<http://www.carfac.be/>

Van: firebird-***@yahoogroups.com
[mailto:firebird-***@yahoogroups.com]
Verzonden: vrijdag 2 december 2016 16:34
Aan: firebird-***@yahoogroups.com
Onderwerp: RE: [firebird-support] reset autoincrement field

To see current generator value

select gen_id(generator-name, 0) from rdb$database

To set generator value

set generator generator-name to value;

From:
firebird-***@yahoogroups.com<mailto:firebird-***@yahoogroups.com>
[mailto:firebird-***@yahoogroups.com]
Sent: Friday, December 2, 2016 10:13 AM
To:
firebird-***@yahoogroups.com<mailto:firebird-***@yahoogroups.com>
Subject: [firebird-support] reset autoincrement field

How can I reset an autoincrement field in firebird 3 ? I used identity to
make an autoincrement field.

Thanks.

Nico Speleers
Analyst

Carfac bvba

Driving on experience

Rijksweg 53
9680 Maarkedal
Tel. +32 55 23 00 00
Fax +32 55 31 00 95
***@carfac.com<mailto:***@carfac.com>
www.carfac.be<http://www.carfac.be/<http://www.carfac.be%3chttp:/www.carfac.
be/>>
[cid:***@01D11613.C23F19C0]<http://www.facebook.com/groups/12070918
1286476/>[cid:***@01D11613.C23F19C0]<http://www.linkedin.com/compan
y/hdc-software-nv> [cid:***@01D11613.C23F19C0]
<https://twitter.com/carfacbvba>

[Beschrijving: Beschrijving: Beschrijving: CarfacAS
(klein)]<http://www.carfac.be/>

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]





[Non-text portions of this message have been removed]
Norbert Saint Georges nsg@tetrasys.eu [firebird-support]
2016-12-02 15:41:23 UTC
Permalink
Post by Nico Speleers - Carfac BVBA ***@carfac.com [firebird-support]
How can I reset an autoincrement field in firebird 3 ? I used identity to
make an autoincrement field.
<alter column definition> ::=
<name> RESTART [ WITH <value> ]

http://firebirdsql.org/file/documentation/release_notes/html/en/3_0/rnfb30-ddl-enhance.html
--
Norbert Saint Georges
http://tetrasys.fi



------------------------------------

------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu. Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-***@yahoogroups.com
firebird-support-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-***@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/
Helen Borrie helebor@iinet.net.au [firebird-support]
2016-12-03 18:53:06 UTC
Permalink
Post by Nico Speleers - Carfac BVBA ***@carfac.com [firebird-support]
How can I reset an autoincrement field in firebird 3 ? I used
identity to make an autoincrement field.
In your Fb 3 installation is the /doc/ directory, where you will find
the release notes in PDF form. IDENTITY is documented on page 69
(page 79 by the PDF numbering), including the syntax for making the
(otherwise inaccessible) generator restart with a different value.

Syntax works ONLY with an IDENTITY column.

To re-initialise to zero:

alter table aTable
alter column aTable_ID RESTART

The next number generated will be 1.

To re-intialise to some other number:

alter table aTable
alter column aTable_id RESTART WITH n

The next number generated will be (n+1).

Remember to COMMIT if you are not using isql with autoddl on.

HB

Loading...