I am using an SQL that includes query_to_xml:
select query_to_xml('select 1+1 answer', true, true, '') as_xml;
When any SQL with query_to_xml is executed in Squirrel SQL it will result in:
| as_xml |
+--------------------+
|<UnknownType (2009)>|
With the same JDBC driver, credentials and a Java class the SQL will result in the expected XML output:
| as_xml |
+------------------------------------------------------------+
| <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">|
| |
| <answer>2</answer> |
| </row> |
I can execute other functions in Squirrel and they will respond, like select version().
Is this a known feature in Squirrel?
If you are using the latest squirrel client, Go to File, Global Preferences-> Data Type Controls, check the box under Unknown DataTypes section.
Rerun the query, it might work.
It seems to be an issue with the text option output for SQL results. It works if you change to the tabular output. Go to the Session menu and click "Session Properties". On the "General" tab under "Output" change "SQL Results" from Text to Table and rerun the query. You may need to close the existing results tabs first.
If this fixes it please add a bug report so that it can be fixed in the future.
Related
I have a unixODBC connection with hive:
isql -v Hive
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
E.g. select install_dt, count(1) from device_metrics.sometable where install_dt >= '2020-04-10' group by install_dt;
Returns expected results.
I would like to run this query but with some hive variable settings. For example, I would liek to set the execution engine to be mr not default tez. When connected to hive directly, outside of odbc I can just do:
set hive.execution.engine=mr;
select ... [my query to run with mr here...
With isql I tried this:
SQL> set hive.execution.engine=mr;
SQLRowCount returns -1
I'm not really sure what SQLRowCount returns -1 but I guess it means either it was an error or no rows were affected?
Either way, I tried running my select query again after trying to configure this setting:
SQL> set hive.execution.engine=mr;
SQLRowCount returns -1
select install_dt, count(1) from device_metrics.sometable where install_dt >= '2020-04-10' group by install_dt;
When I then look at our hadoop running applications page I can see my second attempt at the query but it's still running with tez. Expected and desired behavior was that it would run with mr.
Is it possible configure hive settings with unixODBC connection? If so How can I tell hive to use mr engine and not tez?
I type a lot of sql select statements. I'd like to be able to configure datagrip to replace the character string 'ssf' into 'select * from '. Is this possible?
It is, go to Settings | Editor | Live Templates where you can create snippets.
But see that there are templates already!
So, sel is actually will be transformed into SELECT * FROM.
To try this, type sel and press TAB.
Good news, it is possible to configure DataGrip to replace a specific string with and expanded string! What other editors (Sublime, VS Code, SSMS, Azure Data Studio, MySQL Workbench) call "snippets," DataGrip and other JetBrains products call "Live Templates" as described for WebStorm here.
There is an existing snippet for what you ask to do, which when expanded will also leave the cursor in the correct location for you to immediately start entering the desired source.
As #moscas mentions in his answer, the live template sel is what you are looking for.
When sel is typed, followed by Tab (or what your DataGrip "By default expand with" setting is) sel will expand to
> `SELECT * FROM ...;`
The cursor will be where the ellipsis (...) is after the expansion. Other useful existing templates are listed here and I recommend building muscle memory for selc and selw. I also created a selt for SELECT TOP(10) * FROM ...; and you should be able to create a new one with using the ssf string using resources linked.
Here are the other default snippets/Live Templates that ship with DataGrip and expand with default expansion:
+---------------------------------------------------------------+
| Abbreviation | Expands to |
+---------------------------------------------------------------+
| ins | INSERT INTO ... (...) VALUES (...);" |
| sel | SELECT * FROM ...;" |
| selc | SELECT count(*) FROM ... alias WHERE alias. ...;" |
| selw | SELECT * FROM ... alias WHERE alias. ...;" |
| upd | UPDATE ... SET ... = ... WHERE ...;" |
+---------------------------------------------------------------+
I am testing monetdb for a colunmnar storage.
I already installed and run the server
but, when I connect to the client and run a query, the response does not show the time to execute the query.
I am connecting as:
mclient -u monetdb -d voc
I already tried to connect with interactive like:
mclient -u monetdb -d voc -i
Output example:
sql>select count(*) from voc.regions;
+---------+
| L3 |
+=========+
| 5570699 |
+---------+
1 tuple
As mkersten mentioned, I would read through the options of the mclient utility first.
To get server and client timing measurements I used --timer=performance option when starting mclient.
Inside mclient I would then disable the result output by setting \f trash to ignore the results when measuring only.
Prepend trace to your query and you get your results like this:
sql>\f trash
sql>trace select count(*) from categories;
sql:0.000 opt:0.266 run:1.713 clk:5.244 ms
sql:0.000 opt:0.266 run:2.002 clk:5.309 ms
The first of the two lines shows you the server timings, the second one the overall timing including passing the results back to the client.
If you use the latest version MonetDB-Mar18 you have good control over the performance timers, which includes parsing, optimization, and runtime at server. See mclient --help.
I am trying to run a mysql script on centos. I have following mysql installed.
mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------------------------------+
| innodb_version | 5.6.25-73.1 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.6.25-73.1 |
| version_comment | Percona Server (GPL) |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+------------------------------------------------------+
My sample script looks like:
DELIMITER //
DROP TRIGGER IF EXISTS trg_table1_category_insert;
DROP TRIGGER IF EXISTS trg_table1_category_update;
CREATE TRIGGER trg_table1_category_insert
AFTER INSERT
ON
table1_category
FOR EACH ROW
BEGIN
insert into table1_category_history (
table1_category_history_id,
table1_id,
transaction_start_date
) values (
new.table1_category_id,
new.table1_id,
new.create_date
);
END;
//
CREATE TRIGGER trg_table1_category_update AFTER UPDATE on table1_category FOR EACH ROW
BEGIN
insert into table1_category_history (
table1_category_history_id,
table1_id,
transaction_start_date
) values (
new.table1_category_id,
new.table1_id,
new.create_date
);
END;
//
DELIMITER ;
My database utilizes utf8 encoding. While importing this file in database on mysql client it keeps throwing
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '//
CREATE TRIGGER trg_table1_category_update AFTER UPDATE on ta' at line 1
I do not see any syntax error while using the delimiter, also it works on some machines absolutely fine, i have googled almost 100s of links and tried all the ways with downgrading/upgrading mysql server/client , my.cnf, charset etc it is not helping me out. Can anyone please help me on this? Can there be any settings done at client level to interpret it correctly.I am using the same version client that comes with mysql server installation.
Running a select statement in psql returns output nicely formatted in a table:
mydb=# SELECT * FROM users WHERE login = 'foo';
id | login | first_name | last_name
------+-------+------------+------------
1000 | foo | Dude | HowdyHeyYo
However, I often run my database queries in IRB, and use datamapper to connect to Postgres. What's the best way to get the output formatted similarly to the above table when running a query like this using Ruby and Datamapper?
>> User.all(:login => 'foo')
psql is formatting the output into the ASCII table layout. psql is the equivalent to IRB at that point, so you'd either have to write a method to call that would wrap your query and output formatted results, or use some IRB plug-ins.
Take a look at IRBTools and, in particular, hirb.