Showing posts with label Express-C. Show all posts
Showing posts with label Express-C. Show all posts

Friday, December 18, 2015

DB2: The last query...

Bodensee/Lake Constance in Winter
I am always amazed at what DB2 is capable of. Today, I would like to show you my last DB2 query for this year. All what is needed comes with the regular DB2 and is even included in the free DB2 Express-C. You could run it in your own DB2, locally or in the IBM DB2 on Cloud service on Bluemix. Enough of introduction, enough of my words for this year, here is my last DB2 query for this year...


[hloeser@magicmachine]$ db2sampl

  Creating database "SAMPLE"...
  Connecting to database "SAMPLE"...
  Creating tables and data in schema "HLOESER"...
  Creating tables with XML columns and XML data in schema "HLOESER"...

  'db2sampl' processing complete.

[hloeser@magicmachine]$ db2 connect to sample

   Database Connection Information

 Database server        = DB2/LINUXX8664 10.5.6
 SQL authorization ID   = HLOESER
 Local database alias   = SAMPLE


[hloeser@magicmachine]$ db2 "select substr(note_text,length(note_text)-36,18) from in_tray where source='CHAAS'"

1                
------------------
Enjoy the holidays

  1 record(s) selected.



Tuesday, May 6, 2014

Tuning your DB2 CLP environment: Customize appearance and editor

Tuning World Bodensee via Wikipedia
Over the last weekend, the annual Tuning World Bodensee was guest at the Messe Friedrichshafen (exhibition center and fair grounds). More than 100,000 people interested in car tuning traveled to Friedrichshafen. "Tuning" can be trying to get more performance out of engine or to customize the car to the personal style. With DB2, you can customize the command line processor to your personal style and preferences. Let's have a look at the available tuning options.

All the recent versions of DB2 provide three environment variables to tune the editing experience in the interactive DB2 CLP: DB2_CLP_EDITOR, DB2_HIST_SIZE, and DB2_CLPPROMPT. The first variable, DB2_CLP_EDITOR, is used to specify an external editor to be used for editing SQL statements. On my Linux system, I did the following:

export DB2_CLP_EDITOR=gedit

Now you can edit previous statements using the EDIT command. "EDIT 1" would call the editor with the first statement in the command history, "E 1" would do the same. To know which statements are available, use the HISTORY command or its short version "H". The maximum number of available commands is determined by the variable DB2_HIST_SIZE. It accepts numbers from 1 to 500.

export DB2_HIST_SIZE=100

To reduce the number of statements listed with the HISTORY commands, you can limit it: "H 10" would return the last 10 statements in history, "H R 5" would return the last five in reverse order. Instead of the option "R" you could also use the full word "REVERSE", e.g., "H REVERSE" or "HISTORY REVERSE". Editing commands is fun, but actually executing them is probably why they were edited. To execute a specific statement from the history, you can utilize RUNCMD. The short version is just "R" and a valid parameter would be the number corresponding to a "historic" statement.

Both RUNCMD and EDIT, if not invoked with a number, will pick the newest statement in history. Both also accept negative numbers with "-1" being the most recent statement.

What is left is to "decorate" the command line processor in your personal style. DB2_CLPPROMPT is used to modify the command prompt. It accepts different tokens and most characters. Here is my version which prints the current database name followed by "=> ":

export DB2_CLPPROMPT="DB: %d => "

Here is a small sample session with the bew prompt:

 DB:  => connect to hltest

   Database Connection Information

 Database server        = DB2/LINUXX8664 10.5.3
 SQL authorization ID   = HLOESER
 Local database alias   = HLTEST

DB: HLTEST => values 'Good Morning'

1         
------------
Good Morning

  1 record(s) selected.

DB: HLTEST => e -1
DB: HLTEST => values 'That''s it, good bye!'
Do you want to execute the above command ? (y/n) y

1                 
--------------------
That's it, good bye!

  1 record(s) selected.

DB: HLTEST => h r
4    h r
3    values 'That''s it, good bye!'
2    values 'Good Morning'
1    connect to hltest
DB: HLTEST =>

Monday, April 30, 2012

DB2 10.1 for LUW now online!

My alarm went off, I just tested that the DB2 Information Center for DB2 10.1 is now online. You can also now download DB2 trial editions or the free DB2 Express-C at this website. What more to say? To get hands-on experience and insight into the new edition, you can also take a look at where and when the free DB2 bootcamps are offered. The same applies of course to InfoSphere Warehouse and other related, updated products.


Tuesday, November 22, 2011

All the news: DB2 Express-C with PL/SQL, new TPoX version, DS 3.1, and hello to all PMs

I am in between business trips and there is not much time for looking deeper into any specific problems. But I wanted to touch base on few things that are new:

  • DB2 Express-C, the free to download, free to use edition of DB2 LUW now includes the Oracle compatibility. That is, you can develop and use PL/SQL packages with DB2, for free, even in production. Although it still says "9.7.4" at the DB2 Express-C download site, when you click through it then offers DB2 9.7.5 for download. I just tried it.
  • A new version of TPoX, the open source XML database benchmark, has been released. Most changes are to the workload driver. I know that some of you use the workload driver not just for TPoX and DB2.
    BTW: The DB2 Technology Explorer/Management Console includes a so-called Workload Multiuser Driver (WMD) that can be handy, too.
  • IBM Data Studio 3.1 is out since few weeks and Data Studio will replace the DB2 Control Center in the near future. There is a so-called Administration Client (which is small) and a Full Client. Both have a different download size and a different function set. An overview of what is included and which database servers in addition to DB2 are supported is listed at this Data Studio V3.1 features document.
Last but not least I would like to say Hello to all Project Managers (link to Dilbert comic). Dining out and working in large projects never will be the same again...

Friday, November 26, 2010

Black Friday Special: DB2 for free (no MIR required)!!!

We have THE most important shopping day in the US today: Black Friday. Shops are trying to lure in shoppers with rebates and specials, some require complicated mail-in rebates (MIRs). Let me point you to a very valuable product and it is entirely free and doesn't require a mail-in rebate: DB2 Express-C.

The free product includes free autonomics and free pureXML and much more. Get DB2 Express-C today and if you want some great free books and tools, let me know.

Tuesday, August 3, 2010

Fat-free and now in a light edition: DB2 Express-C download image

I am one of the gazillion users of DB2 Express-C. And that's why I am really happy that (from now on I hope) there is a "light edition" of the DB2 Express-C download image. You can still download the full edition which features text search, the Control Center, languages other than English, and some other things I consider minor. For the most of us it means less to download with the next (or this) release, thus an even faster upgrade cycle.

And when your spouse asks what you are doing, remember to point out: It's the light edition now (and fat free).

Wednesday, June 16, 2010

Catching up - 5 weeks in review

Well, I am currently catching up. A very busy time, some offline vacation, a surgery with time off, and some busy days getting back "into" work have left me not posting anything for the past 5 weeks. And what has happened!

DB2 9.7 FP2 (9.7.2) is out now with some fixes and new features - more on that in a separate post. For those on DB2 Express-C, the good news is that IBM has updated the free to develop, free to deploy, free to distribute version of DB2, too.

Speaking of free products, there is a free eBook Getting started with IBM Data Studio for DB2. Actually, this is old news, but what is new is that there is now a free German version of that book, named Einstieg in IBM Data Studio für DB2.

While I am at German and Germans, I was surprised to read that SAP is buying Sybase. Apparently, this deal is to move SAP into the mobile space, not so much about Sybase's dying database business. And there was another interesting acquisition in the database area, too.
Teradata has bought xkoto and apparently during that process stopped selling new GRIDSCALE licenses. There is discussion, not just at IBM business partners like Triton Consulting, about the increased importance of the DB2 pureScale technology as it suddenly becomes the only available solution to address scalability and cluster high availability. Speaking of DB2 pureScale, the related Information Center is now open to the public.

There was so much more in the past 5 weeks, I will update you once Germany has won the soccer world championship... ;-)

Thursday, April 1, 2010

(Updated) Strange error on insert into DB2

Some time ago I ran into a strange error when inserting data into a table using DB2 9.7.1 on Windows. To prepare for a database class I wanted to create a table with the 50 best movies ever. I started off with:

create table bestmovies(rank int unique not null, title varchar(100), url varchar(200))
DB20000I  The SQL command completed successfully.

So far, so good. Trying to be a good teacher I planned to show how to document database objects:
comment on table bestmovies is 'Table with the best movies ever,  URL is for imdb links'
DB20000I  The SQL command completed successfully.

Then I inserted some data to try out that it works. For later importing from a file was planned.
insert into bestmovies values(1,'The Shawshank Redemption','http://www.imdb.com/title/tt0111161/')
DB20000I  The SQL command completed successfully.

Doing a multi-insert also worked:
insert into bestmovies values(2,'The Godfather','http://www.imdb.com/title/tt0068646/'),(3,'The Godfather: Part II','http://www.imdb.com/title/tt0071562/')
DB20000I  The SQL command completed successfully.

However, later I ran into a strange error:
insert into bestmovies values(20, 'The Hottie & the Nottie','http://www.imdb.com/title/tt0804492/')
DB21034E  The command was processed as an SQL statement because it was not a valid Command Line Processor command.  During SQL processing it returned:
SQL0114N  The value(s) violate a semantic condition defined on the table "HLOESER.BESTMOVIES".   SQLSTATE=42603

I couldn't find a description of the error code or the error message in the DB2 Information Center. The error code is not listed. Usually I am not using comments on my regular test tables, so I am not sure what it means. Do you have any clue or give me pointers? This looks very interesting.

Update: After dropping the comment on the table, it now works.

Tuesday, March 2, 2010

Understanding Processor Value Units (PVUs)

When you are a software developer, you don't necessarily have insight into the pricing and sales process. From coding days I know how to hook up functionality to a license server and how to make sure features are only used when money was paid (that's the part regarding job security). So recently I tried to learn more about how DB2 software (distributed software in general) is priced or what forms the basis for pricing. The magic term in IBM lingo is PVUs or Processor Value Units.

PVUs are not based on how much you actually paid for the machine, but how valuable in processing power (from IBM's view) your machine is. A number is first determined for a processor core, then the numbers are added up to account for all cores in a machine. A table with up-to-date PVUs for the different processor types is maintained at http://www-01.ibm.com/software/lotus/passportadvantage/pvu_licensing_for_customers.html. The new POWER7 processors, e.g., have 120 or 100 PVUs per core, depending on the server model. Based on the table you can do the math and can come up with the total PVUs your machine has, e.g., 800 PVUs. A different (and I can't say simpler or more comfortable) way is to use the "processor value unit calculator" where you click through a decision tree.

An introduction to the DB2 pricing with some background on why PVUs were introduced is this article by Paul Z. and Deb Jenson.

If you have read all this, you can determine how valuable your machine is. To no surprise, there are other licensing option like per server or per socket which are only available for certain DB2 editions (usually only the "smaller" editions). If you don't (want to) care about PVUs, maybe why not just start with the free DB2 Express-C?

Tuesday, October 13, 2009

Teeth Whitening Tips and DB2 Express-C (and not Oracle 11g XE)

Recently, I stumbled over a so-called gadget that allows to add daily teeth whitening tips to my blog. How nice. But why would I want to have it on my blog? And are there that many tips that it warrants daily updates?

Today I was reminded about the teeth whitening because DB2 users have a lot to smile because of recent news and announcements (and white teeth may be of advantage on those group photos at the upcoming IOD Conference). DB2 users also have a reason to smile when reading the latest (no-) news on Oracle 11g Xpress Edition (XE). According to the Infoworld article, a no-cost edition of Oracle 11g is still a year out. Compare that with how quickly after the DB2 9.7 release the free DB2 Express-C was available. DB2 users can utilize it for developing applications, deploying it at no charge or even distribute it with their applications. And it is available on several platforms and operating systems.

BTW: Did I add the gadget to my blog? Check it out...

Wednesday, July 1, 2009

Two essential links: IBM Data Studio and a free book

With a new version like DB2 9.7 there are other things you need or want, too. It's like with a house. You first remodel or upgrade something, then you need matching colors and hence buy new curtains, replace the carpet, try to get rid of some relatives (just kidding). Anyway, the point is that there are usually some added, often hidden costs or other issues.

The good news is that it is different and even free with DB2. Because you probably already got your free copy of DB2 Express-C 9.7, here are two essential links to make your database server remodeling complete (no relatives involved): There is a upgraded and free IBM Data Studio to take care of DB2 administration (and it has lots more). Finally, the free book "Getting Started with DB2 Express-C" has been updated to version 9.7 as well.

With all the bills coming in around the start of a new month, it is always good to see that there is so much good stuff freely available...

Friday, February 6, 2009

DB2 jack-of-all-trades: Hybrid, native, bilingual, pureXML

Today I was pointed to the FAQ for XML:DB again and asked whether DB2 is a hybrid system or an XML-enabled database. In those FAQs they distinguish between a native XML database (DB), an XML-enabled DB, and a hybrid XML DB. So what is DB2?

In the FAQ they use "hybrid" in a different meaning than IBM is doing for DB2 as "hybrid database system". XML:DB is defining a hybrid XML database as one that can be both native and XML-enabled. DB2 is called a hybrid system because it is both a (native) relational database system as well as a (native) XML database system. What does native mean? It indicates that the data, either relational or XML, is processed and stored in its own data model, with its specific semantics. Relational data is stored in an optimized row format, relational operators work on the data, and the output are result sets. XML data is stored in its (native) hierarchical format, as optimized, easy-to-navigate trees on disk. The XQuery Data Model (XDM) is an inherent part of the storage structure, the processing of XML data - sequences of nodes and atomic values are core to the processing. Based on this infrastructure DB2 is a native XML database and a hybrid database (relational, XML) - not a hybrid XML database.

Furthermore, DB2 is also bilingual as it understands both SQL statements and XQuery statements. If you write a regular "SELECT ... FROM ... WHERE ..." you are by default in the relational world, using SQL. Thanks to part 14 of the SQL standard, XML is a "relational" data type and we have XML-specific functionality and defined semantics. Users can embed XQuery statements into SQL.
By using the keyword "xquery" in front of a query, users can switch to the XQuery mode and directly issue an XQuery statement. Something like "xquery for $i in .... where ... return ..." is understood by DB2, users who are coming from the XML and XQuery world do not need to learn SQL and can immediately start leveraging their experience.
BTW: Both SQL statements and XQuery statements end up in a single compiler and optimizer since everything is deeply integrated. It's similar to speaking two languages and having only one (!!!) brain.

As shown, DB2 is a bilingual, hybrid database. To top it off, you can download and use it for free as DB2 Express-C.