SQL Oracle developer with hive connection - using of temp tables - hive

We are using hive connection with oracle SQL developer tool.
Is it possible to use temporary tables while querying external tables through sql developer tool?
Tried this , But doesn't work
CREATE PRIVATE TEMPORARY TABLE my_temp_table (
id NUMBER,
description VARCHAR2(20)
);
Error :
SQL Error: [Cloudera]HiveJDBCDriver ERROR processing query/statement. Error Code: 40000, SQL state: TStatus(statusCode:ERROR_STATUS, infoMessages:[*org.apache.hive.service.cli.HiveSQLException:Error while compiling statement: FAILED: ParseException line 1:7 cannot recognize input near 'CREATE' 'PRIVATE' 'TEMPORARY' in ddl statement:28:27, org.apache.hive.service.cli.operation.Operation:toSQLException:Operation.java:335,

You can't use an Oracle Database syntax against a hadoop/HIVE target, even with the Oracle Big Data Connector.
Here are the CREATE TABLE clauses available to you
https://docs.oracle.com/en/bigdata/big-data-sql/4.0/bdsug/bigsqlref.html#GUID-066A4568-9F95-4305-A1A5-7BC3E5DF35AF
Here are examples for querying your external table
https://docs.oracle.com/en/bigdata/big-data-sql/4.0/bdsug/bigsql.html#GUID-0628EC5B-E013-40DF-A025-908019F4E681

Related

SQL (DB2) Creating table by selecting from other table

I´ve read several discussions and websites about creating a SQL query to create a table by selecting data from other table, but none of them solved my issue. I don´t know what else to do.
I am working on a SQL script to run a sequence of selects and creates do resume some data. I´ve been using this SQL queries on a SaS server using DB2 data. Now I need to migrate to Dbeaver to using other sources.
I just want to create a table by selecting some columns and data from other table, for this simple example :
"CREATE TABLE DB2XXXX.PaidResume AS
(SELECT HistoricalPaid.AccountNumber AS CONTA
FROM DB2XXX.HistPaid HistoricalPaid
WHERE HistoricalPaid.AccountNumber = 'XXXXX');
All I got it this error
Error occurred during SQL query execution
SQL Error [42601]: ILLEGAL SYMBOL "<END-OF-STATEMENT>". SOME SYMBOLS THAT MIGHT BE LEGAL ARE:. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.19.26
If I just exclude the "CREATE TABLE DB2XXXX.PaidResume AS" and run the select only, it works.
You must include WITH DATA or WITH NO DATA at the end of the SQL statement. For example:
create table u as (select a from t) with data;
See example at db<>fiddle.

How to truncate or delete partition from db2 using bigsql?

I have table in db2 (using bigsql) that is partitioned as per date on IBM BigInsights
table_name_abc
20150810
data corresponding to partition
20150811
data corresponding to partition
....
what I want is to delete particular partition say 20150810 or delete data from that partition
I tried this
db2 "truncate table test_schema.table_name_abc where partition_date = 20150810";
But it gave following error
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "where" was found following "test_table".
Expected tokens may include: "". SQLSTATE=42601
Can someone please instruct on how to do this?
Solved it by using the following command
db2 "ALTER TABLE test_schema.table_name_abc DROP PARTITION (partition_date = 20150515)";
Adding it as answer just in case someone needs it

Redshift create Query failed: ERROR: syntax error at or near "identity"

I am new at redshift. I am trying to create table which having auto increment id.
I used syntax from documentation, yet its throwing an error
Query failed: ERROR: syntax error at or near "identity"
My sql statement is as follows
CREATE TABLE xyz (
id BIGINT identity(0, 1) NOT NULL,
orderid BIGINT )
This query runs perfectly fine with PSQL client to Redshift. There may be client issue using that you're connecting to Redshift. Try using some other client or programming language like Java, Ruby, Python etc.

Create an external table Informix

I am trying to create an external table in Informix.
create external table test_table(cols varchar(10))
using ( datafiles('C:/sample.txt'), format 'delimited', deluxe);
But it gives me an error :
[Error Code: -26174, SQL State: IX000] Incorrect DATAFILE entry C:/sample.txt.
Can anyone suggest me the right syntax for path entry...
I have also tried.
load from "C:\sample.txt" insert into test_table;
Which gives me a syntax error. Any help is greatly appreciated!!
About the create external table
Did you check the correct syntax at the manual? (here)
At datafiles keyword, you don't use the correct syntax.
This probably will work.
create external table test_table(cols varchar(10))
using ( datafiles('DISK:C:\sample.txt'), format 'delimited', deluxe);
About the load
It isn't a native command from the engine, is a specific command of dbaccess utility.
So, if you aren't using dbaccess, it will not work.
BTW, the syntax of your load is correct...

HIve CLI doesn't support MySql style data import to tables

Why can't we import data into hive CLI as following, The hive_test table has user, comments columns.
insert into table hive_test (user, comments)
value ("hello", "this is a test query");
Hive throws following exception in hive CLI
FAILED: ParseException line 1:28 cannot recognize input near '(' 'user' ',' in select clause
I don't want to import the data through csv file like following for a testing perpose.
load data local inpath '/home/hduser/test_data.csv' into table hive_test;
It's worth noting that Hive advertises "SQL-like" syntax, rather than actual SQL syntax. There's no particular reason to think that pure SQL queries will actually run on Hive. HiveQL's DML is documented here on the Wiki, and does not support the column specification syntax or the VALUES clause. However, it does support this syntax:
INSERT INTO TABLE tablename1 SELECT ... FROM ...
Extrapolating from these test queries, you might be able to get something like the following to work:
INSERT INTO TABLE hive_test SELECT 'hello', 'this is a test query' FROM src LIMIT 1
However, it does seem that Hive is not really optimized for this small-scale data manipulation. I don't have a Hive instance to test any of this on.
I think, it is because user is a built-in (Reserved) keyword.
Try this:
insert into table hive_test ("user", comments)
value ('hello', 'this is a test query');