[Solved] Auto increment
[Solved] Auto increment
I was using the base application in OO and the auto increment feature worked once and I saved the database I created shut down and left. I came back to add more data to it and found the data base was deleted, so I recreated it and the field that it uses for a primary key is ID and it work before on auto increment no it does not work at all even when I delete the field and add it back an manualy set it to auto increment and click save open office sets it back to no instead of yes for auto increment. the database was just for inventory. if some one could tell me how to fix so I don't have to keep putting in the next number in line.
I also uninstalled and reinstalled it nothing else has worked.
thanks.
I also uninstalled and reinstalled it nothing else has worked.
thanks.
Last edited by rmj156248 on Tue Aug 11, 2015 6:10 pm, edited 2 times in total.
open office 4.1.1 on windows 7
Re: Auto increment
menu:Tools>SQL...
menu:View>Refresh Tables
Code: Select all
ALTER TABLE "Your Table Name" ALTER COLUMN "ID" SET GENERATED BY DEFAULT AS IDENTITY;
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Auto increment
got unexpected token
Unexpected token: GENERATED in statement [ALTER TABLE "Products"ALTER COLUMN "ID" SET GENERATED]
Unexpected token: GENERATED in statement [ALTER TABLE "Products"ALTER COLUMN "ID" SET GENERATED]
open office 4.1.1 on windows 7
Re: Auto increment
Does this work?
Code: Select all
ALTER TABLE "YourTableName" ALTER COLUMN "ID" INTEGER GENERATED BY DEFAULT AS IDENTITY;
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Auto increment
yes it worked but will I have to keep doing it every time I have a new database
open office 4.1.1 on windows 7
Re: Auto increment
If you define the table initially to have an auto incrementing primary key, that setting should be permanent. I don't know why that wasn't working on your database.
When you close down the database, be sure to wait a few seconds before turning off the computer. Base files are complex and you should give the system time to finish all of the tasks.
When you close down the database, be sure to wait a few seconds before turning off the computer. Base files are complex and you should give the system time to finish all of the tasks.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
- Posts: 12
- Joined: Wed Jul 24, 2019 8:52 am
Re: [Solved] Auto increment
I have imported a calc spreadsheet into Base and the ID prime key does not increment, tried the SQL command but I get "2: Primary key not allowed in statement [ALTER TABLE "Membership" ALTER COLUMN "ID" INTEGER GENERATED BY DEFAULT AS IDENTITY]" as status.
OpenOffice 4.1.6 Mac Os 10.11.6
-
- Posts: 12
- Joined: Wed Jul 24, 2019 8:52 am
Re: [Solved] Auto increment
Solved it by making a new DB and importing Calc data.
OpenOffice 4.1.6 Mac Os 10.11.6
-
- Volunteer
- Posts: 1549
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: [Solved] Auto increment
Scarsax2018, the command
will only work on an empty table. If the table already has data in it you need to prime the number generator.
where XX = 1 + the largest ID value currently in the table.
Code: Select all
ALTER TABLE "Membership" ALTER COLUMN "ID" INTEGER GENERATED BY DEFAULT AS IDENTITY
Code: Select all
ALTER TABLE "Membership" ALTER COLUMN "ID" INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH XX)
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.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
-
- Posts: 12
- Joined: Wed Jul 24, 2019 8:52 am