Ask Your Question

How to add FK index & relationships

asked 2018-07-23 05:15:33 +0200

trueriver gravatar image

updated 2018-07-23 05:16:41 +0200

I want to add a non unique index to a table? I want to index foreign keys to (hopefully) speed up one-many joins.

Is there a way to tell LO base about PK-FK relationships? If so how?

How do I do this in LO base:

1) with an embedded database?

2) with a remote mariadb? (connected as mysql, jdbc)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-07-23 05:36:27 +0200

Ratslinger gravatar image

updated 2018-07-23 05:54:57 +0200


This information is basically obtained from the appropriate documentation of the database you are working with. For example, in HSQLSB v1.8 embedded ( LO current default) a unique constraint is:

ALTER TABLE <tablename> ADD [CONSTRAINT <constraintname>] UNIQUE (<column list>);

Please see the docs for v1.8 Chapter 9 for more information -> Hsqldb User Guide

For MariaDB the documentation is here -> MariaDB Documentation

Also, many relations can be set from the main Base screen menu under Tools->Relationships. For this, see the LO documentation found here -> LibreOffice Base Handbook in Chapter 3 - Tables.

edit flag offensive delete link more


Thanks that's helpful

What I also needed to know (and found by luck) was where to enter non-SELECT queries.

For anyone else similarly stuck, you don't enter them as a query in the UI; they go under Tools -> SQL from the main menu bar.

Also these queries do not seem to be saved. Remember to ctrl-a ctrl-c and copy the text into a file somewhere. If you don't do so, and make a trivial mistake, you have to type it all again (please correct me if I am wrong -- in this case I would love to be)

trueriver gravatar imagetrueriver ( 2018-07-24 12:00:02 +0200 )edit

@trueriver Actually, you can store & sometimes process non-SELECT statements in the Query section by clicking on the Run SQL command directly icon on the toolbar. Storage there is helpful for all DB types. However please note only some external DB's will execute from there but not for all statements. It's a bit of trial & error. Embedded will NOT execute from there but you can store the statements for future use.

Also, peruse the documentation as it will contain much of this information

Ratslinger gravatar imageRatslinger ( 2018-07-24 15:11:36 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-07-23 05:15:33 +0200

Seen: 116 times

Last updated: Jul 23 '18