Sql imported drop table if exists and command line exec


#1

Hi,

(1) Is there a way to specify to the sql importer to drop a table if it exists?

(2) Can I execute command line w/o explicitly going into mapdql so I can write bash jobs?
I.e.,
$MAPD_PATH/bin/mapdql -db mapd -p HyperInteractive “DROP TABLE IF EXISTS mytable”;

Thanks!


#2

Hi,

  1. Docs here https://www.mapd.com/docs/latest/mapd-core-guide/loading-data/

It is confusing from the docs but the --truncate option actually drops the the table and recreates it.

  1. Yes you can echo commands into mapdql or redirect from a file

eg:

echo "select count(*) from flights_2008_10k;" | bin/mapdql -p HyperInteractive

or

bin/mapdql -p HyperInteractive < mysqlfile.sql

regards