Import data from text file. I can't create primary key and relations.

Hello everyone.

I have a problem.
I imported data into tabels form text files but tabels don’t have created primary keys so I can’t create relations.

How I can create/add primary key into tabel in libreoffice?

I attached my libreoffice base file and text files which I imported.

You didn’t import data into tables as you may believe. It seems you created this DB with connection to text files by stating Connect to existing database then selecting Text in the dropdown list. This creates read only links to the .txt files. If you actually want these to be tables an entirely different approach is needed.

The question is what do you actually want?


Since I believe you wanted actual tables and not links, here is how. First create new empty database.

Do the following for each text file (one file at a time), copy data into empty Calc sheet. It will prompt for Text import - make sure Tab is selected under Separator Options then select OK. Now data is in columns. Select all columns & rows of this data in the spreadsheet. Right click & select Copy. Go to new database. In the area where tables are listed (all blank for new DB), right click & select Paste. A dialog appears. Fill each page as desired and click Next to proceed until final step when actual table is created (at end may ask if Key is to be created). All these decisions are yours.

Did this with your info (you may want to re-do the way you want).

Sample: CreateDBfromTextFiles.odb

If this answers your question please click on the :heavy_check_mark: (upper left area of answer).