There is a ‘rule’, I think it was created by Tom Kyte, stating: If you can do it in SQL, do it in SQL. I came across some code the other day that makes perfect sense to do then you are running an Oracle 10g (or earlier) instance. I rewrote the code to use only the EMP and DEPT tables to protect the suspects and maybe innocent.
The function defined is something like this:
Years ago I wrote an article (in Dutch) on the XML functions in Oracle SQL. It can be found here
It describes how to create an xml document as an XMLType with an Oracle SQL Query.
The query that is described is based on a pretty simple table, with no relationships. I'm creating a new course based on a datamodel we created years ago, that contains data. I wanted to abstract some of that data (more...)
firstname.lastname@example.org > select banner from v$version;
Oracle Database 12c Enterprise Edition Release 22.214.171.124.0 - 64bit Production
PL/SQL Release 126.96.36.199.0 - Production
CORE 188.8.131.52.0 Production
TNS for Linux: Version 184.108.40.206.0 - Production
NLSRTL Version 220.127.116.11.0 - Production
email@example.com > select value from nls_database_parameters where parameter='NLS_CHARACTERSET';
firstname.lastname@example.org > ! (more...)
Chris Saxon posted a nice quiz regarding a pitfall when creating tables with VARCHAR2-columns: when you are not explicit in specifying the length-semantics ( CHAR or BYTE ), a session parameter, which may vary, is used.
This is a short follow-up of his story, which shows more pitfalls when creating views and selecting from those.
We end up in a structure which can – by definition – contain only 1 byte, but actually shows containing (more...)
There continues to be a disproportionate amount of hype around 'NoSQL' data stores. By disproportionate I mean 'completely and utterly out of scale with the actual problems of the vast majority of companies'. I wrote before about 'how NoSQL became more SQL'. The point I made there is now more apparent the more I work with companies on Big Data challenges.
There are three worlds of data
This year, from June 22 - June 26, the best convention in the world, ODTUG’s KScope14 will be held in Seattle, Washington. I am already looking forward to meeting some ‘old’ friends again, creating new friends and seeing some of the best content by presenters from all over the world.
Some of the presentations I am looking forward to:
In the Developer’s Toolkit track:
Here is a restriction of the cardinality hint in conjunction with the materialize-hint ( note: both are undocumented but sometimes of great use ):
we cannot tell the optimizer in the outer query ( the one that uses the materialized subquery ) about the cardinality of the materialization, this can only – and then not always – be done within the materializing query.
The example to show that is stolen from Tom Kyte’s Presentation S13961_Best_Practices_for_Managing_Optimizer_Statistics_Short. (more...)
It’s sometimes amazing, how many bugs there are still with elementary SQL.
Here is one concerning updatable views:
email@example.com > create table t ( v varchar2(30) );
firstname.lastname@example.org > create view v as
2 select v as dontdothatman, v as canbelostwheninserted
3 from t;
email@example.com > insert /* this is fine */ into v
2 values('fine', 'fine');
1 row created.
firstname.lastname@example.org > select * from v;
Before I joined Cloudera, I hadn't had much formal experience with Big Data. But I had crossed paths with one of its major use cases before, so I found it easy to pick up the mindset.
My previous big project involved a relational database hooked up to a web server. (more...)
Just a quick code snippit. I do a lot of data pumps to move schemas between different databases; for example taking a copy of a schema to an internal database to try to reproduce a problem. Some of these schemas have some very large tables. The large tables aren’t always (more...)
Yesterday I attended John King (@royaltwit) session on Oracle 12c for developers. He gave an overview of all the goodies that are available to us as developers. The whole plugging and unplugging of database, though very cool and exiting, is most likely not very relevant to most developers.
When he (more...)
Since PL/SQL now is closely integrated into SQL, we hence can happily state
email@example.com > with function bestpractice return varchar2
4 return 'Do not use PL/SQL when it can be done with SQL alone !';
5 end bestpractice;
Recursive subquery factoring (AKA Recursive Common Table Expressions) has been available in Oracle since version 11g R2 was launched sometime around 2009. I always thought of it as a replacement for the connect by clause and just another way to write hierarchical queries, so I never really took the time (more...)
The PIVOT and UNPIVOT operators were introduced in Oracle 11g and the other day I helped out a friend using these operators.
He wanted the data in the columns to be "shifted to the left". To explain a little more, take a look at the following data:
ID V1 V2 (more...)
This year is kind of fun, my birthday is on November 12th (next Tuesday, if you want to send gifts). That means it will fall on 11/12/13. Even better perhaps, katezilla's
birthday is December 13th. 12/13/14. What does this have to do with SQL?
Someone mentioned to me last night (more...)
It seems that sometimes you need a non-unique index to enforce a unique constraint even if this constraint is declared as not deferrable.
firstname.lastname@example.org > create table strange(i int not null, j int not null);
email@example.com > alter table strange add constraint unique_i unique(i) not deferrable
Thank you all who attended my sessions at NYOUG Fall Conference this morning. I appreciate spending you most precious commodity - your time
- with me. I sincerely hope you found both the presentations enlightening as well as entertaining.
Please see the details of the sessions below along with the (more...)
Always check out the original article at http://www.oraclequirks.com for latest comments, fixes and updates.
I was trying to call function DECOMPOSE while investigating a strange problem I had with some Unicode strings that could not be properly indexed by Oracle Text and, amazingly, I found out that most (more...)
Those who visit SQL.ru often know what the title means. It’s a very simple yet powerful technique to group data which doesn’t seem appropriate for grouping at first sight.
I learned this very nice tip long time ago but often have to re-think before applying it to SQL or (more...)
This is a translation of my German article which was requested through “Google Translate” many times. It seems that throughout the years this error and its mostly simple causes haven’t lost their significance. Here’s a sample scenario: A table’s VARCHAR2 column shall be searched for numeric entries; We use a query with a WHERE clause […]