For SQL query in Spark.
For read, we can read jdbc by
CREATE TEMPORARY TABLE jdbcTable
USING org.apache.spark.sql.jdbc
OPTIONS dbtable ...;
For write, what is the query to write the data to the remote JDBC table using SQL?
NOTE: I want it to be SQL query. plz provide the pure "SQL query" that can write to jdbc when using HiveContext.sql(...) of SparkSQL.
Yes, you can. If you want to save a dataframe into an existing table you can use
and if you want to create new table to save this dataframe, the you can use
You can write the dataframe with jdbc similar to follows.
An
INSERT OVERWRITE TABLE
will write to your database using the JDBC connection: