How do I specify a Primary Key when creating table from .ods file

I am using Linux Mint Debian Edition 201403 English 64bit, with LibreOffice 4.1.3.2, and am pretty much a newbie with Linux and LibreOffice.

I use Base to create a new database, then want to create a table using one sheet from an existing .ods file. The sheet contains a column with unique data that I want to use as the primary key. I am unable to create a table using my chosen primary key, I can only create a table with a ‘default’ primary key of ID which is a number that increments by one for each row in the sheet.

I open the .ods file in Calc, select the sheet I want to use, the sheet has unique column names as the first row, and I Edit-Copy marking all data rows as well as the first row. In Base, I select Tables, Edit, Copy-Paste and get a Copy Table window. I check ‘Definition and data’, ‘Use first line as column names’ and ‘Create Primary Key’, then in the ‘Name’ box I type the name of the column containing unique data (rather unimaginatively in this case named ‘Key’). I then click Next. I get a popup saying 'The following fields have already been set as primary keys : Key ’ and I have to go back. If I do not specify my own column name, the table gets created using ID as the primary key.

Is there a different way I can create a table in Base using a .ods sheet to load the data and the column names, specifying my own primary key ?

Ron

and ‘Create Primary Key’

that step is wrong. Your table has already got a suitable column, so you do not need to create a new one. Instead click on Next and import the columns and Next again. Now you are in “Type formatting” and here you have to do a lot.

To get the primary key, right click on the column name and click on item “Primary key”. You will see the little yellow key in front of the name.

In addition you have to examine the “Column information” very carefully for each (!) column name. In most cases the automatic detection is wrong and you have to set the correct type and range manually.

OK, I will try that when I get the PC running again :frowning:

Ron

The sheet contains a column with unique data that I want to use as the primary key. I am unable to create a table using my chosen primary key, I can only create a table with a ‘default’ primary key of ID which is a number that increments by one for each row in the sheet.

I don’t really understand WHY it is so important that you do not have a plain integer (auto-value) column as your PK. There are some pretty good arguments that integer auto-increment PKs are less problematic than ‘meaningful’ user-generated PKs! See the first answer HERE.