SQLEditor: Copy and Paste, foreign keys

This document explains how copy and paste works if you copy an object
that has a foreign key relationship, but you don't copy the target of that relationship.

This works both within a document and between documents

Note that if you copy objects within a document, or between documents then the object will copied as an object (It isn't converted to SQL text in this case).

SQLEditor stores both object data and SQL text on the clipboard at the same time.

As an alternative to copy/paste you can also drag with the option or alt key held down.

The original document

This is the base document. We're going to select and copy just Table1

original document

The new document

This is the new document. Note how this Table2 is different from the Table2 in the first document. (Although it does have the same field id to link to)

the new document

After pasting the object

If you paste Table1 into this document it should automatically find and connect to the table Table2 in this document.
Even though it is a different object to the one in the original document, because you didn't copy the original target and there is no other alternative, SQLEditor assumes that you want to use the existing Table2.

after pasting the object

But what if I copy both source and target?

If you copy both sides of the relationship and paste them somewhere then that specific relationship is retained.
This happens even if there is an object with the same name as one or both of the new objects.

In this example Table2 already exists, but we paste in the two objects from the original document.
This results in the new Table2 becoming Table2_1 to avoid a conflicting name, however despite this, the connection
remains between Table1 and Table2_1

after pasting the object

Does this have limitations?

Yes, the object names must match exactly on both table and field/column names for the matching to work.

Finally, if all else fails and SQLEditor can't figure it out, you can always reconnect the objects manually.

I want to drag instead of using the clipboard

As an alternative to copy/paste you can also drag with the option or alt key held down.

This works otherwise in exactly the same way

Support Updates


Contact Us

To contact us with a support issue please email:

support@malcolmhardie.com