Mike Schaeffer's Weblog
Mon, 21 May 2007
New Computer... Links from the old...
Tomorrow, my employer is replacing my three year old Dell D400 with a nice new Compaq nc2400. I have to admit that I'm a bit apprehensive about the switch; My D400 works quite well and shows few signs of decay. But, I also remember feeling the same way about the D400. Maybe the Compaq will be as good as the last Compaq I regularly used and be another nice suprise. Anyway, as part of clearing out the old machine, here are a few links I've found that I'd like to preserve. No promises on content, but you might find at least one of them to be interesting if you read this blog.

reddit this! Digg Me!

[/tech/links] permanent link

Tue, 15 May 2007
An Emacs Blog
I just started reading this blog, but it already looks useful: m-x all-things-emacs.

reddit this! Digg Me!

[/tech/tips] permanent link

Oracle and Table Descriptions
The other day, I created a table in Oracle with the following command. This is written in the subset of SQL known as DDL, or Data Defintion Language.
CREATE TABLE COMMON.SAMPLE_TABLE (
  NAME      VARCHAR(64) NOT NULL,
  STATUS    CHAR(1),
  X_C       NUMBER (10),
  Y_C       NUMBER (*,10) NOT NULL, 
  Z_C       NUMBER (*,10),
  FOO       VARCHAR2 (18) NOT NULL, 
  BAR       DATE,
  BAZ       TIMESTAMP
 )
/
Once the table is created, it is then possible to ask the database to describe the table:
common@XE> desc COMMON.SAMPLE_TABLE;
 Name                          Null?    Type
 ----------------------------- -------- ----------------------------
 NAME                          NOT NULL VARCHAR2(64)
 STATUS                                 CHAR(1)
 X_C                                    NUMBER(10)
 Y_C                           NOT NULL NUMBER(38,10)
 Z_C                                    NUMBER(38,10)
 FOO                           NOT NULL VARCHAR2(18)
 BAR                                    DATE
 BAZ                                    TIMESTAMP(6)
For some reason, the syntax of Oracle's description of the table's definition is entirely different than the syntax of the DDL used to define the table in the first place. Not only does the description not use DDL, minor details are different too. For example, the relative placement of the nullability (NOT NULL) of a column and its data type is reversed from one representation to the other. This makes converting a table description into corresponding DDL a trickier process than it would be otherwise. Another difference (loss?) is that the DDL syntax allows for table specific attributes and the description syntax does not. That means that the table's full description really might look something like this:
CREATE TABLE COMMON.SAMPLE_TABLE (
  NAME      VARCHAR(64) NOT NULL,
  STATUS    CHAR(1),
  X_C       NUMBER (10),
  Y_C       NUMBER (*,10) NOT NULL, 
  Z_C       NUMBER (*,10),
  FOO       VARCHAR2 (18) NOT NULL, 
  BAR       DATE,
  BAZ       TIMESTAMP
 )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING
/
So, if you rely on a table description as the basis for creating a duplicate copy of a table, you not only have to do specific work to convert the description from description syntax to DDL, the DDL you end up with will likely be incomplete. While I am sure that there is an excellent reason for the syntactic split between the two types of table descriptions, I honesly cannot think of it. My current best theory is that SQL*Plus and SQLNET cannot handle non-table returns from a database request. Because of this, the table description has to itself be a table. You could even make the argument that this is the 'right' way to do things, since it gives you a table description in a form (a table) that database code should easily be able to manipulate. However, the description is itself incomplete, so I'm not sure how useful that explanation is.

I'm not a database guru, but it seems like another way to handle this possible limitation is to have the table description query return a one row, one column table with a BLOB or VARCHAR2 containing the DDL description. SQL*Plus could then special case the display of this query to make it look nice on the screen. (SQL*Plus already does special case desc queries, since their display does not honor calls to SET PAGESIZE. If you really do need table information in tabular form, there are always the ALL_TABLES and ALL_TAB_COLS views. (Of course, a really wonderful solution to all of this would be to make those views writable, somehow standardize them, and then skip the DDL entirely. :-)

reddit this! Digg Me!

[/tech/general] permanent link

Fri, 04 May 2007
Baby Fortunes, part 8
"A major problem facing mothers is that ovens are self-cleaning but kids are not!"

reddit this! Digg Me!

[/personal/ryan_charles] permanent link