Every database: Oracle, mySQL, SQL, etc., has support for the Command Line interface for executing queries. Just google for usage of the command line terminal for the database you are using; you should be getting the enough documentation online.
For database interactions, BP has built in VBOs which simplifies things for you as the data returned from the sql queries is available as collections to play around. Otherwise, reading the sql query output from the terminal in to BP Data Items or Collections is not straight forward.