How to link inserts? Last insert id or insert aliasing?

Does liquibase have a way to link related rows when doing inserts? Consider the following migration, is there a way to link the role to the person?


In sql I would normally do this by getting the last insert id but I think this is something liquibase could handle. In other systems I’ve used this is accomplished by giving insertions unique id’s within the context of the change set. It might look something like this:


Effectively after each insert, if an id attribute is given to the insert, then it get’s put in to a map with the last insert id. Then any reference to this row that follows can use the id that has been assigned. Does anything like this exist?

It does not currently exist, but it would be good to add.  I created an issue for it to track (

What I have done in the past is use the tag with a subquery in later inserts:

                          insert into role (person_id, role) select id, 'manager' from person where first_name='Bob' and last_name='Smith'    

Not as nice of a solution, but it works.