It depends on the type of database (MySQL, Postgres, Oracle, etc.) and the privileges of the database user.
If the application connects to the database using an administrator account, code execution is usually possible. It is straightforward on SQL Server, using xp_cmdshell. Other databases require more involved techniques. SQLmap, the most popular SQL exploitation tool, mentions this:
Support to execute arbitrary commands and retrieve their standard output
on the database server underlying operating system when the database software
is MySQL, PostgreSQL or Microsoft SQL Server.
For MySQL at least, I think it uses the trick of writing to a PHP file mentioned by Fleche.
From a defence point of view, this is the reason why you should never have your application connect as administrator.