Its error when I send a query to mysql from clickhouse server.
Mysql can't understand query like
SELECT /*+ MAX_EXECUTION_TIME(1000) */ column1, column2
from mysql_tables.table1
from clickhouse through a table created with the mysql engine.
How to correctly enter the MAX_EXECUTION_TIME() constraint? to the mysql engine when creating a table like
CREATE TABLE mysql_tables.table1
(
`id` Int32,
`status` Int32
)
ENGINE = MySQL('host',
'db',
'table1',
'user',
'password',
)
SETTINGS [MAX_EXECUTION_TIME=1000]
or to the query itself?
Unfortunately, you can't pass comment to MySQL
According to
https://clickhouse.com/docs/en/engines/table-engines/integrations/mysql/#read-write-timeout
you can set up SETTINGS read_write_timeout=XXX
Unfortunately, this is not max execution time, and query still run on MySQL side
but if you will use ProxySQL, and setup default_query_timeout
https://proxysql.com/documentation/global-variables/mysql-variables/
it could work
Related
I have 3 MySQL/MariaDB servers running for application development and testing:
MySQL Community Server 5.7.32
MySQL Community Server 8.0.16
MariaDB Community Server 10.4.12
The servers are configured to run on different ports on the same machine.
SELECT ##sql_mode for all servers:
MySQL Community Server 5.7.32: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
MySQL Community Server 8.0.16: STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
MariaDB Community Server 10.4.12: NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION
I stumbled across some SELECT queries in old code I maintain whose fails to run, for e.g. searching a date with a given pattern. The queries look like this:
SELECT * FROM `userTable` WHERE `birthDate` LIKE '2020-%-%';
SELECT * FROM `userTable` WHERE `birthDate` LIKE '%12%';
The table looks like this:
CREATE TABLE IF NOT EXISTS `userTable` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` TEXT COLLATE utf8_unicode_ci,
`birthDate` DATE,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
When I run the queries on MySQL Community Server 8.0.16 they fail with the error Error Code: 1525. Incorrect DATE value: '2020-%-%'. and Error Code: 1525. Incorrect DATE value: '%12%'..
MySQL Community Server 5.7.32 and MariaDB Community Server 10.4.12 executes the queries successfully.
Why does MySQL Community Server 8.0.16 fails to execute these SELECT queries?
PS: The first SELECT query can be written as
SELECT * FROM `userTable` WHERE YEAR(`birthDate`) = 2020;
to run on all 3 servers.
EDIT: It's a bug in MySQL Community Server 8.0.16 and fixed in version 8.0.22.
You should be comparing a bona fide date column against valid date literals, not strings, e.g. to find records in 2020:
SELECT *
FROM userTable
WHERE birthDate >= '2020-01-01' AND birthDate < '2021-01-01'; -- sargable :-)
Or maybe:
SELECT *
FROM userTable
WHERE YEAR(birthDate) = 2020; -- not sargable though :-(
Does anyone know how to retrieve UUID via HSQLDB.
For example when i try
SELECT UUID();
via MYSQL it works fine. But the same statement doesn't work with HSQLDB.
The following methods achieve the corresponding purpose
VALUES (UUID())
CALL(UUID())
SELECT UUID() FROM (VALUES(0)) t;
Is there a way which is same for mysql and hsqldb?
HSQL doc says that UUID has been activated. http://hsqldb.org/doc/guide/builtinfunctions-chapt.html
Thanks.
Turn on the MySQL compatibility mode in HSQLDB and it will allow your SELECT statement:
http://hsqldb.org/doc/2.0/guide/compatibility-chapt.html#coc_compatibility_mysql
Is there a way which is same for mysql and hsqldb?
Only way i can think off.
Create a table DUAL in HSQLDB
CREATE TABLE DUAL (
id INT
);
So you can use
SELECT UUID() FROM DUAL LIMIT 1;
Then the query should work the same in both MySQL and HSQLDB.
DUAL in MySQL is a non existing dummy table.
I have install mysql server version 5.7.9 but mysql json functions not working like jsn_length(),jsn_merge()..etc.
I have created a table with one field.
CREATE TABLE t1 (
jdoc json DEFAULT NULL
)
ENGINE=InnoDB DEFAULT CHARSET=latin1;
After insert data in this field with json format:
"{"name": "pankaj", "lname": "kumar"}"
then I execute this query
select jsn_length(jdoc) from t1
I am getting this type error in phpmyadmin:
MySQL said: Documentation
1305 - FUNCTION jsn_length does not exist
I think your problem is syntax related.
Instead of :
select jsn_length(jdoc) from t1
Run :
select JSON_LENGTH(jdoc) from t1
The query listed below is running fine on localhost but it's somehow hanging when executed remotely targeting my service provider database (both the PHP script and the SQL query in the phpMyAdmin console hang), although every chunk is returning the expected table when run individually.
What's wrong? Any suggestions on how to make it shorter or simpler and thus help the remote MySQL?
SELECT * FROM `Table1`
WHERE `Tag1` IN (
SELECT DISTINCT `Tag1` FROM `Table2`
WHERE `Tag1` NOT IN (
SELECT `Tag1` FROM `Table2` WHERE `Tag2` = '$keyWord'
)
)
I run this query
CREATE TEMPORARY TABLE usercount SELECT * FROM users
I get this message
Your SQL query has been executed successfully ( Query took 0.1471 sec )
But when I try to access the newly created table using
SELECT * FROM usercount
I get this error
#1146 - Table 'abc_site.usercount' doesn't exist
Not sure why, I need to mention that I've did a good share of googling beforehand.
My version of PHPMyAdmin is 3.5.2.2 and MySQL 5.5.27
PHPMyAdmin (or rather PHP) closes the database connection after each screen. Thus your temporary tables disappear.
You can put multiple SQL statements in the SQL query box in PHPMyAdmin; this should be executed as one block and thus the temporary table is not deleted.
Temporary tables are temparar and after use thay Delete.
for example ,when insert data into database , first we can insert into temp table and thus when complete transaction , then insert into main table.
EXAMPLE :
//------------------------------------------
CREATE TEMPORARY TABLE TEMP
(
USERNAME VARCHAR(50) NOT NULL,
PASSWORD VARCHAR(50) NOT NULL,
EMAIL varchar(100),
TYPE_USER INT
);
INSERT INTO TEMP VALUES('A','A','A','1');
SELECT * FROM TEMP
//-----------------------------------------
Show A,A,A,1