I cannot set a Primary key after Importing Tables into LibreBase

I copied and pasted Tables from Excel into LibreBase but there is no option to set a Primary key in the menu.

I was given an option of creating a Primary Key when Importing but LibreBase did not allow me to choose my own PK Field so I chose No.

How can I set a PK now?

Thanks for any help offered

crossposting: Importing from Calc: Cannot set datatype for PK field that already has Values

Hello,

You have not posted any specifics which is important in answering the question - LO version, OS database being used.

Please see my answer in this post → How can I load csv data to base?

Also, don’t think you can copy & paste from Excel. Calc is OK.

Edit:

…why would Libre make this so difficult.

It is not.

As stated in the link in the answer above, the documentation shows this process. This was again noted in my first comment below. Here is a screen shot showing this same item:

\

Once you get to this section of the dialog (of course using the Next buttons) you would need to right mouse click on the field which you want to set as the primary key.

In the documentation, Chapter 3 Tables - Page 43

Apologies, I copied and pasted from Calc. Im using LibreOffice 6.2 and Windows 10

The documentation does show where the primary key is applied in the process used. However, to actually change what you have already, what database are you using?

Note: v6.2 is still general; I am using v6.2.3.2 - sometimes makes a difference.

Firebird database

Firebird has a number of issues in this regard. With HSQLDB you can simply edit the table & set the Primary Key. With Firebird there are a number of errors to get around.

I would recommend to start over but differently. First create a new table definition and set all fields to needs. Then copy data data from Calc and use the append data setting to add the data to existing definition.

I deleted the DB and created a new one using HSQLDB. I copied and pasted from Calc and did not a add a PK because the wizard said I could create a PK from existing fields in the Type Format window, however there was no option to do so. There is only an option to add a Unique Index when the table has been saved but no option to add a PK. The Pk is the most important part of any DB, why would Libre make this so difficult.

Please see edit in my answer

I don’t see any edit

When you copy and paste a table from Calc into Base you do not have to create a new field to use as a PK field.

Instead you can assign a PK to a Field or Fields already in your Table following these steps:

  1. Copy and Paste your Table from Calc into Base
  2. Name your Table and click next
  3. Choose the fields you want in your Table and click next
  4. Right Click the Field that you want to set as the PK and choose PK

This should have been made clear by a simple note in the window. Instead Base has the PK option hidden which is not helpful.

This was made clear in the documentation.