I have a very simple query on maria 10.0.32
SELECT v.id, v.ver, DENSE_RANK() OVER (PARTITION BY id ORDER BY id) AS dense_rank FROM v;
I receive the following error:
Check the manual that corresponds to your MariaDB server version for the right syntax to use near '(PARTITION BY id ORDER BY id) AS dense_rank FROM v
MariaDB supports DENSE_RANK as of version 10.2. You are using 10.0.32, so the function is not supported in your version. https://mariadb.com/kb/en/library/dense_rank/
Related
I'm facing a strange error. I have a 5.5.5-10.1.20-MariaDB install on my local mac (brew) and a 5.5.52-MariaDB on my prod server (centos7). My local DB content is a copy from my server DB. I've executed this query on local:
## CREATE DIRECT RELATION BETWEEN JOURNAL AND PUBLICATION
INSERT INTO journal_publication (journal_id, `publication_id`) (
select issues.journal_id as journal_id, publications.id as publication_id from issues
join publications on issues.id = publications.`issue_id`
where publications.id Not In (select distinct publication_id from journal_publication)
);
It works fine and takes only less than a second to execute.
Now when I try the exact same query on my prod server, the query is never ending and takes all CPUs. Moreover, I've tried to EXPLAIN the query, it works fine on my local:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY issues index PRIMARY issues_journal_id_foreign 5 NULL 70993 Using index; Using temporary
1 PRIMARY publications ref publications_issue_id_foreign publications_issue_id_foreign 5 pubpeer.issues.id 1 Using where; Using index
2 MATERIALIZED journal_publication index NULL PRIMARY 8 NULL 143926 Using index
Whereas the same query on my Prod returns an error:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO journal_publication (journal_id, `publication_id`)
(select issues.j' at line 2
Again, the content of the two DBs are identical, primary keys and indexes are set equally. For the record, when I try and execute this query:
select issues.journal_id as journal_id, publications.id as publication_id from issues
join publications on issues.id = publications.`issue_id`
where publications.id Not In (select distinct publication_id from journal_publication;
either on local or prod takes only a second.
Have you got any clue or process I could follow to help me understand these differences?
Thanks.
Xavier
MariaDB server versions < 10.0 only support EXPLAIN SELECT
MariaDB server versions >= 10.0 support additionally EXPLAIN
UPDATE, EXPLAIN INSERT and EXPLAIN DELETE
Please note that the version string 5.5.5-10.1.20-MariaDB means MariaDB 10.1.20, the 5.5.5 prefix is required since MySQL replication would break, since it supports only 1 digit numbers for the major version.
See also EXPLAIN UDATE/INSERT/DELETE in MySQL and MariaDB
Really enjoyed using Rmarkdown/Knitr execution of SQL chunks recently, however it seems there is a limitation for more complex queries. I've been using a Redshift data base with an RJDBC powered connection.
Specifically using Common Table expressions with INNER JOIN:
```{sql, connection=redshift, output.var="Field_count"}
WITH
cte AS (
SELECT DISTINCT field
FROM
table
WHERE date >= '2017-01-01'
)SELECT count(DISTINCT field)
FROM cte
INNER JOIN table_2 t2 ON t2.join_here = cte.join_here;
```
I've successfully used CTE and INNER JOIN in individual queries, but combining them leads to an error:
Error in .verify.JDBC.result(r, "Unable to retrieve JDBC results set for ", : Unable to retrieve JDBC result set for WITH
cte AS (
SELECT DISTINCT field
FROM
table
WHERE date >= '2017-01-01'
)SELECT count(DISTINCT field)
FROM cte
INNER JOIN table_2 t2 ON t2.join_here = cte.join_here; ([Amazon] (500335) One query is expected: WITH
cte AS (
SELECT DISTINCT field
FROM
table
WHERE date >= '2017-01-01'
)SELECT count(DISTINCT field)
FROM cte
INNER JOIN table_2 t2 ON t2.join_here = cte.join_here;) Calls: <Anonymous> ... dbSendQuery -> dbSendQuery -> .local -> .verify.JDBC.reslt Execution Halted
It appears that this is being translated wrongly/duplicated on the querying out of the RStudio session.
Is this a known limitation? If so is it documented anywhere?
Is this a known bug? If so is it in an existing issue?
EDIT: This is only visibly happening within the knit process, individually running chunks interactively returns expected results.
I'd suggest trying another version on Redshift JDBC driver.
I got the same error, however, it was while using Pentaho so mileage may vary. I didn't find any documentation or other info related to this. My problem got solved by switching away from the newest driver version. I was using RedshiftJDBC4-1.2.1.1001.jar (JDBC 4.0 compatible) and switched to RedshiftJDBC4-1.1.10.1010.jar.
My development os is Linux(raspberry pi).
I installed sqlite3 and it is latest version.
explain query plan returns value
for example
sqlite> explain query plan select * from test_table
0|0|0|SCAN TABLE test_table (~100000 rows)
but my result is
:
sqlite> explain query plan select * from test_table
0|0|0|SCAN TABLE test_table
(~100000 rows) is not shown.
what is problem? Thanks
The documentation says:
Warning: The data returned by the EXPLAIN QUERY PLAN command is intended for interactive debugging only. The output format may change between SQLite releases.
You are using another SQLite release, and the output format indeed changed.
I have the below script in the Source Editor in a SSIS package and I get an error. I change to a Select * and it works. I'm not sure why this is not working. It works in P/SQL. Any help would be appreciated!
This works in my package:
select * from Test
This does not work in my package (but works in PL/SQL) and I get the below error.
select * from (select id, color, shape,
dense_Rank () Over (Partition By id order by id desc as SeqRank)
) x
Error: 0xC0202009 at Data Flow Task, OLE DB Source [111]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14.
Best approach for this questions is instead of creating a subquery one could create a CTE. A CTE is compatiable with SSIS.
I am trying to convert column data to xml format, but I get this error message:
The query fails because all columns types are currently not supported.
CREATE TABLE EMP(NAME VARCHAR2(10 BYTE))
INSERT INTO EMP VALUES ('C');
INSERT INTO EMP VALUES ('A');
INSERT INTO EMP VALUES ('T');
SELECT xmlelement("NAME",NAME) FROM EMP;
I am using:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
SQLTools 1.5.0 Beta build 9 as EDITOR
Why is this error arising??? What is the solution for this?
I've found the answer:
select dbms_xmlquery.getxml('select * from EMP') from dual;
This is more of a workaround and not a solution.
I was having the same problems as sam - also running a SELECT xmlelement statement, also using SQLTools. One difference is that I was running Oracle DB version 11.2.0.2.0.
I found that if I ran the statement in SQLPlus, it was able to display the result.
SQL> SELECT XMLELEMENT("name",ename) FROM scott.emp WHERE ROWNUM < 3;
XMLELEMENT("NAME",ENAME)
--------------------------------------------------------------------------------
<name>SMITH</name>
<name>ALLEN</name>
If I ran the statement in SQL Developer, it tried to display the results, but only showed (XMLTYPE).