In DB2 is there a length restriction on the SQL statement? - sql

In some older versions of DB2, I know there's a limit to how many characters can be in the SQL passed to the database. (32767, I believe) -- is this the case in the latest versions of DB2?

As of version 8.2, 2MB is allowed. See: SQL statement size limit increased to 2 MB

Related

SSMA - Rows counts are not matching after migration from Oracle to SQL Server

I migrated data from Oracle to SQL Server, the rows count in Oracle is around 820m rows, but when SSMA finished the migration "message said 100% successfully migrated" the rows count in SQL Server was around 745m rows.
Is there a limit on the number of rows?
There is no limit on number of rows for SSMA
Please keep in mind that Oracle has read consistency, meaning that the cursor will produce rows as they were in the beginning of select. Maybe, when SSMA started to run there were 745m in Oracle.

oracle sql query limit

I have to read data in batches and I want to know what is the limit of an sql-query and is there any limit in JDBC driver as well for max-sql-query size. I am using oracle 19c database.

SSIS performance vs OpenQuery with Linked Server from SQL Server to Oracle

We have a linked server (OraOLEDB.Oracle) defined in the SQL Server environment. Oracle 12c, SQL Server 2016. There is also an Oracle client (64 bit) installed on SQL Server.
When retrieving data from Oracle (a simple query, getting all columns from a 3M row, fairly narrow table, with varchars, dates and integers), we are seeing the following performance numbers:
sqlplus: select from Oracle > OS File on the SQL Server itself
less than 2k rows/sec
SSMS: insert into a SQL Server table select from Oracle using OpenQuery (passthrough to Oracle, so remote execution)
less than 2k rows/sec
SQL Export/Import tool (in essence, SSIS): insert into a SQL Server table, using the OLEDB Oracle for source and OLEDB SQL Server for target
over 30k rows/second
Looking for ways to improve throughput using OpenQuery/OpenResultSet, to match SSIS throughput. There is probably some buffer/flag somewhere that allows to achieve the same?
Please advise...
Thank you!
--Alex
There is probably some buffer/flag somewhere that allows to achieve the same?
Probably looking for the FetchSize parameter
FetchSize - specifies the number of rows the provider will fetch at a
time (fetch array). It must be set on the basis of data size and the
response time of the network. If the value is set too high, then this
could result in more wait time during the execution of the query. If
the value is set too low, then this could result in many more round
trips to the database. Valid values are 1 to 429,496, and 296. The
default is 100.
eg
exec sp_addlinkedserver N'MyOracle', 'Oracle', 'ORAOLEDB.Oracle', N'//172.16.8.119/xe', N'FetchSize=2000', ''
See, eg https://blogs.msdn.microsoft.com/dbrowne/2013/10/02/creating-a-linked-server-for-oracle-in-64bit-sql-server/
I think there are many way to enhance the performance on the INSERT query, I suggest reading the following article to get more information about data loading performance.
The Data Loading Performance Guide
There are one method you can try which is minimizing the logging by using clustered index. check the link below for more information:
New update on minimal logging for SQL Server 2008

Oracle 12c documentation for changes / new features to SQL

I just found out that Oracle 12c supports correlating a query several levels deep which is unsupported in 11g and previous versions.
select
*
from
tab1 a
where
not exists
(select
*
from
(select
*
from
tab2 b
where a.X = b.X))
But I could not find this documented in Oracle website. Is there any other such hidden SQL features added to Oracle 12c? Are all such changes to SQL in 12c documented somewhere?
To explain this we need to dive into history a little bit.
Ability to use correlated sub-queries with more than 1 level was also in Oracle 10g R1 and it was properly documented (https://docs.oracle.com/cd/B14117_01/server.101/b10759/queries007.htm) back those days...
Oracle performs a correlated subquery when a nested subquery
references a column from a table referred to a parent statement any
number of levels above the subquery.
... but it was not properly working. :)
So starting with Oracle 10g R2 this functionality was disabled and documentation had changed.
Also (if you have an access) you can see Bug 15990897 : QUERY WITH CORRELATED VARIABLE USED IN 2ND LEVEL SUBQUERY FAILS WITH ORA-904 on Metalink (Fixed in Product Version 12.1.0.1.0). I'm not sure why it's considered as a bug given that it works according to documentation (10g R2, 11g R1, 11g R2) but that is how it is.
So, functionality was disabled after 10.1 and before 12.1 but documentation even for 12.2 (https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/Using-Subqueries.html) says
Oracle performs a correlated subquery when a nested subquery
references a column from a table referred to a parent statement one
level above the subquery.
Cut a long story short, this functionality is enabled in 12c R1 and 12c R2 but documentation is not fixed and apparently there is no mentioning about this improvement in New Features guide.
PS. As far as I remember standard SQL 2003 allows correlation only to one level deep - everyone is welcome to check (http://www.wiscorp.com/sql_2003_standard.zip).
But Oracle has a lot of improvements above the standard anyway.

Can you name a single popular database that doesn't support LIMIT statement?

Drupal uses db_query_range() for the reason that not all databases support LIMIT,
can you name a few?
DB2, MSSQL, Oracle, and Informix all do not support LIMIT. As a matter of fact, it's not in the SQL standard. (The standard one is "FETCH FIRST" indeed)
Here is a good source for SQL comparisons: http://troels.arvin.dk/db/rdbms/#select-limit
Microsoft SQL Server does not support LIMIT. It supports the TOP statement which can be used to accomplish similar things. The primary limitation with TOP is the inability to specify an offset.
ms sql, oracle.
and actually LIMIT doesn't exists in ANSI SQL '92 which all modern databases should follow. so currently it's just an unnecessary extension/syntactic sugar/specific sql dialect
DB2, Oracle, and MS SQL Server do not support the LIMIT clause.
Google for <database name> LIMIT, and you'll get to know the equivalent supported clause for that database, or whether LIMIT itself is supported.
On the flip side, ANSI-92 SQL provides the ROW_NUMBER() window function for achieving this, which is supported on many databases. See SELECT (SQL) on Wikipedia.