As views. Relational databases have supported storing queries for a long time. If you need to have parameters for queries use stored procedures. You can keep the source code for views and procedures in text files in a git repository like any other source code.
For a DB manager, I use DBeaver, and in the navigation, there is Project->Scripts folder, where I keep most queries which I've written over the past few years and feel like I would need again.