My requirement is that I need to fetch only the list of columns of a hive table via querygrid.
For example, the "help foreign table" gives the col_name,data_type and comment as output.
Can someone please suggest how I can fetch only the col_name?
Try the below in hive
show columns in <table name>
this should return you a list of columns in a table.
Related
Do you have any idea how to do something like this in pentaho?
I have two tables. First table it is source table in mssql and second it is target table in db2.
In first table I have column with type xml. We supply second table this data second table. In second also I have column XML. I would like to compare in pentaho whether the xml value in the second table corresponds to what is in the first table.
You can use combination of "Multiway merge join" & "Switch/Case" step to get the non-matching id from source data. I have prepare a SOLUTION for you. You can get help from here.
Here
Get both table input from MSSQL & DB2
Merge both the table data with condition source.XML=destination.xml with FULL JOIN
Get the source IDs only when IDs are not available in destination table using SWITCH/CASE
Select the IDs and write into the text file
I had a table named abc_foobar in DynamoDB.
I dropped the table using RazorSQL's DynamoDB interface. I log into the AWS console and when I query I don't see the table. However when I try to recreate the table (a table with the same name and same partition key) using the AWS console, I get an error on the form which says that something is "Required" in the form field named "Table Name". I made sure the previous table doesn't exist. Whats going on? I can create a table with any other name but not the same name that was of the earlier table.
Please see the attachment.
I've seen enough answers to know you can't easily check for columns in SQLITE before adding. I'm trying to make a lazy person's node in Node-Red where you pass a message to SQLITE which is the query. Adding a table if it does not exist is easy.
msg.topic='create table IF NOT EXISTS fred (id PRIMARY KEY);'; node.send(msg);
it occurred to me that adding a table which had the names of the fields would be easy - and if the field name is not in the table.... then add the field. BUT you can't add multiple fields at once - so I can't do this...
msg.topic='create table IF NOT EXISTS fred (id PRIMARY KEY, myfields TEXT);'; node.send(msg);
The problem with THAT is that I can't add this in later, there's no way to check before adding a field it the table exists!
This is what I WANT
msg.topic='create table IF NOT EXISTS fred (id PRIMARY KEY, myfields TEXT);'; node.send(msg);
msg.topic='if not (select address from myfields) alter table fred add column address text';
I just cannot think of any way to do this - any ideas anyone (the idea is that the node-red node would input a table, field and value and if the table didn't exist it would be created, if the field didn't exist it would be created, all before trying to add in the value).
You won't be able to make the ALTER TABLE conditional in the SQL itself. You'll need to handle that from your calling script.
Alternately, simply attempt to add the column to the table and accept failure as an outcome. Assuming the table exists, the only failure reason you could encounter is that the column already exists.
If you'd like to do something more graceful, you can check if the column exists in advance, then conditionally run the SQL from your calling application.
I wanted to add a constraint to an existing column in my SQLite database. However, I read that it is not possible to do so.
I tried the solution from How do I rename a column in a SQLite database table?, but there seems to be missing the copying of all the metadata.
I pretty much want an exact copy of a given table, except for the new constraints.
How does the INSERT command look like to copy all the metadata, thus the indexes will increase correctly, for example.
I'm not a heavy user of sqlite3, but you can use the command line to get the data and "create table" and "create index" commands. I am using the 'History' DB from the Google chrome browser which has a table called "visits". The 'mode insert' command says to provide output in a format that can be used to input this data. The '.schema visits' command says to show the 'create table' and 'create index' statements. The 'select..' statement gives you the data. The database I used doesn't seem to have any foreign key constraints, but they could very well be part of the 'create table' information if your DB has any.
sqlite3 History
.mode insert
.schema visits
select * from visits;
I use Navicat and this command to create temp table in sqlite:
create temp table search as select * from documents
Then when i try to query:
select * from search
I got:
no such table: temp.sqlite_master
or:
no such table
The table doesn't appear in table list too, but when I try to create it again I get:
table search already exists
What is the problem? is it from navicat?
You create statement looks correct to me. When you create a temp table it is deleted when you close the connection string used to create the table. Are you closing the connection after you create the table and then opening it again when you are sending the query?
If not, can you include your query statement too?
It's like a bug in SQLite DLL shipped with Navicat. Test it somewhere else worked ok.
Documentation of SQLite tells this about CREATE TABLE:
If a is specified, it must be either "main", "temp",
or the name of an attached database. In this case the new table is
created in the named database. If the "TEMP" or "TEMPORARY" keyword
occurs between the "CREATE" and "TABLE" then the new table is created
in the temp database. It is an error to specify both a
and the TEMP or TEMPORARY keyword, unless the is
"temp". If no database name is specified and the TEMP keyword is not
present then the table is created in the main database.
May be you should accesse table via temp prefix like this: temp.search.