How to implement what MS calls "Autonumber" key field?

Creating tables and queries

How to implement what MS calls "Autonumber" key field?

Postby JSSchiavo » Tue Feb 06, 2018 2:26 am

FOrgive me if this is addressed here somewhere, but I didn't find it.

I'm steeped in the MS "way", and now, converting to OpenOffice, I want to define a table with a primary key that is incremented automatically with each record added: what MS calls "Autonumber".

I need to create a database for folder files, with an integer file number ("ID") that is simply applied by the system.

I haven't found anything similar as yet. Can you direct me?

Many thanks for the help.

Stephen
OpenOffice 4.1.4 on Windows 10
JSSchiavo
 
Posts: 1
Joined: Tue Feb 06, 2018 2:16 am

Re: How to implement what MS calls "Autonumber" key field?

Postby robleyd » Tue Feb 06, 2018 4:26 am

The term used by Base may be either autoincrement or autovalue - see the offline help and search primary keys
Cheers
David
Apache OpenOffice Developer Build 4.2.0 9820 - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 2882
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: How to implement what MS calls "Autonumber" key field?

Postby UnklDonald418 » Wed Feb 07, 2018 12:52 am

One way is to use an SQL command to alter your table.
If your table already has an "ID" integer field as the Primary Key and there are no records in the table then edit the table name and if your table already contains records with previously assigned values for "ID" then you need to replace the 0 with a new start value. Then go to Tools->SQL and execute
Code: Select all   Expand viewCollapse view
ALTER TABLE "YourTableName" ALTER COLUMN "ID" INTEGER GENERATED BY DEFAULT AS IDENTITY (start with 0);
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1199
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: How to implement what MS calls "Autonumber" key field?

Postby Nocton » Sun Feb 11, 2018 2:04 pm

In your table, select Field Type 'Integer' and then in the Field Properties select 'AutoValue = 'Yes'.
OpenOffice 4.2.0 on Windows 10
Nocton
Volunteer
 
Posts: 504
Joined: Fri Nov 05, 2010 10:27 am
Location: UK


Return to Tables & Queries

Who is online

Users browsing this forum: No registered users and 3 guests