You just don’t do it. Manipulating directly the DB is dangerous, error prone and might fail when wordpress or plugins are upgraded or their configuration is changed.
Just create a “one time” plugin that will properly use the relevant APIs to make whatever changes you need.
Alternatively, if you need to do this from the command line, make a plugin which extends the wp-cli so you will be able to use it to trigger the changes.