Ask Your Question
0

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

asked 2014-04-26 04:32:16 +0200

ron_h gravatar image

updated 2015-09-07 20:52:34 +0200

Alex Kemp gravatar image

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

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-02-21 12:25:17.814579

3 Answers

Sort by » oldest newest most voted
0

answered 2014-04-27 10:33:30 +0200

frofa gravatar image

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.

edit flag offensive delete link more
0

answered 2014-04-26 14:29:21 +0200

Regina gravatar image

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.

edit flag offensive delete link more
0

answered 2014-04-27 06:52:35 +0200

ron_h gravatar image

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

Ron

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-04-26 04:32:16 +0200

Seen: 3,076 times

Last updated: Apr 27 '14