How to run custom sql commands to database programatically
I haven't found a way to run this commands from Drupal 8 database connection object. I can only do selects, updates, inserts or deletes

That's not true, you can also run arbitrary queries, e.g.:
\Drupal::database()-&gt;query('TRUNCATE TABLE foo');