Return-Path: Delivered-To: apmail-db-ddlutils-user-archive@www.apache.org Received: (qmail 25511 invoked from network); 6 Feb 2006 21:13:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Feb 2006 21:13:13 -0000 Received: (qmail 34723 invoked by uid 500); 6 Feb 2006 21:13:13 -0000 Delivered-To: apmail-db-ddlutils-user-archive@db.apache.org Received: (qmail 34707 invoked by uid 500); 6 Feb 2006 21:13:13 -0000 Mailing-List: contact ddlutils-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ddlutils-user@db.apache.org Delivered-To: mailing list ddlutils-user@db.apache.org Received: (qmail 34693 invoked by uid 99); 6 Feb 2006 21:13:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Feb 2006 13:13:13 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.43] (HELO brmea-mail-2.sun.com) (192.18.98.43) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Feb 2006 13:13:12 -0800 Received: from fe-amer-05.sun.com ([192.18.108.179]) by brmea-mail-2.sun.com (8.12.10/8.12.9) with ESMTP id k16LCp8u008463 for ; Mon, 6 Feb 2006 14:12:51 -0700 (MST) Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0IUA00G01AKYPG00@mail-amer.sun.com> (original mail from Craig.Russell@Sun.COM) for ddlutils-user@db.apache.org; Mon, 06 Feb 2006 14:12:51 -0700 (MST) Received: from [129.146.30.241] by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0IUA00AFEAXEHQ00@mail-amer.sun.com> for ddlutils-user@db.apache.org; Mon, 06 Feb 2006 14:12:51 -0700 (MST) Date: Mon, 06 Feb 2006 13:12:48 -0800 From: Craig L Russell Subject: Re: oracle database model dangerously broken In-reply-to: <224f32340602040939o46d31571g99ebb21ff3e1c559@mail.gmail.com> Sender: Craig.Russell@Sun.COM To: ddlutils-user@db.apache.org Message-id: MIME-version: 1.0 X-Mailer: Apple Mail (2.746.2) Content-type: multipart/signed; protocol="application/pkcs7-signature"; boundary=Apple-Mail-255--108104609; micalg=sha1 References: <43DF5461.9010600@informaticsmatters.com> <224f32340601310433ubc8c358rd7c95f621ac9e5ab@mail.gmail.com> <43DF6DD8.1000104@informaticsmatters.com> <224f32340601310621k3a90a94dhbf410d5a85e31c83@mail.gmail.com> <43DF8C69.70406@informaticsmatters.com> <224f32340601310912j75dc45admfd439100147ecdbb@mail.gmail.com> <43DF9DC5.6030909@informaticsmatters.com> <224f32340602040939o46d31571g99ebb21ff3e1c559@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --Apple-Mail-255--108104609 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi Thomas, On Feb 4, 2006, at 9:39 AM, Thomas Dudziak wrote: > I've investigated this, and in fact DdlUtils is behaving can be > expected. The reason is this: > > DdlUtils can only fully support schemas in the database that is has > generated. The reason is simply that databases offer a whole lot more > than what DdlUtils can cover. > One aspect of this is that for most if not all databases, DdlUtils > actively supports only a subset of the native types that the database > has to offer. In the case of Oracle, (LONG) RAW is not one of the > supported types (mainly because Oracle discourages from using them in > favor of BLOB). I think that it would be more useful if DdlUtils distinguished between the type actually stored in the database versus the mapping from the abstract type to the actual type. Specifically, I'd like to see it be able to know the difference between a column defined as LONG RAW and BLOB, since Oracle treats them as different. If the user wants to define a real column type they should be able to use either LONG RAW or BLOB. If the user just wants an abstract column type LONGVARBINARY, then I have no problem with DdlUtils creating a BLOB by default (if the user doesn't override the generated column type with a specific type). I haven't looked closely enough into the implications of this, but I have worked with column types on many projects and it is generally useful to separate the actual column type from the generated column type based on an abstract type. Another example is the abstract type String with a length. Databases have different names for various lengths, e.g. VARCHAR, VARCHAR2, CLOB. So the type for a String-6000 will be different for different databases. But the actual column type should always be available to the user of the API. Just a couple of pennies thought, Craig > So while DdlUtils is able to read a table with a LONG RAW column > (which the JDBC driver reports as LONGVARBINARY), DdlUtils will treat > LONGVARBINARY as BLOB because Oracle has no dedicated LONGVARBINARY > type. > That is, if you create a database via DdlUtils and specify > LONGVARBINARY, you'll get a BLOB in the database. Now when you read > this back, the read column will be of type BLOB. And DdlUtils now > ensures that the column won't be changed when altering something other > in the database. > > This may sound a bit complicated, but in the end this serves to > support the following workflow: > > * create db via DdlUtils > * change something in the db model via DdlUtils => DdlUtils ensures > that as few changes as possible will be made to the db > > The crucial thing is that this may conflict with the workflow that > you've tried: > > * create db outside of DdlUtils > * read the model via DdlUtils > * change something in the db model via DdlUtils > > DdlUtils can only fully support one of these workflows, and IMO the > first one is more useful, so that's what DdlUtils focuses on. We're > trying hard to use the native types that the database vendors suggest, > so that even the second workflow works most of the time, but only if > the tables use these suggested types. E.g. if you'd use BLOB instead > of LONG RAW, DdlUtils would not try to change the column. > > Btw, for Oracle it is advisable to specify the platform manually. E.g. > I've changed your code to: > > OracleDataSource ods = new OracleDataSource(); > > ods.setURL("jdbc:oracle:thin:@localhost:1521:orcl"); > ods.setUser("my_user"); > ods.setPassword("my_password"); > > // note the change to BLOB here > String sql = "CREATE TABLE MY_TABLE( " + > "prop_name VARCHAR2(200) NOT NULL PRIMARY KEY, " + > "prop_value VARCHAR2(200), prop_value_ext BLOB)"; > > Connection conn = ods.getConnection(); > Statement stmt = conn.createStatement(); > > stmt.execute(sql); > stmt.close(); > conn.close(); > > String schema = "MY_SCHEMA"; > > // I've tested against an Oracle 10 database > Platform platform = PlatformFactory.createNewPlatformInstance > ("Oracle10"); > > platform.setDataSource(ods); > // the table was created without delimiters, so we should use DdlUtils > in the same way > platform.getPlatformInfo().setUseDelimitedIdentifiers(false); > > Database db = platform.readModelFromDatabase("test", null, schema, > null); > > dumpDb(db); > > // note the new arguments for catalog, schema, table types > System.out.println(platform.getAlterTablesSql(null, schema, null, db, > true, true, true)); > > > Tom Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:Craig.Russell@sun.com P.S. A good JDO? O, Gasp! --Apple-Mail-255--108104609 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGUDCCAwkw ggJyoAMCAQICEB7Y7fLHmKoeHTUdbtYrvpAwDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA1MTIxNTIxNDc0NFoXDTA2MTIxNTIxNDc0 NFowbDEQMA4GA1UEBBMHUnVzc2VsbDEUMBIGA1UEKhMLQ3JhaWcgTGFpcmQxHDAaBgNVBAMTE0Ny YWlnIExhaXJkIFJ1c3NlbGwxJDAiBgkqhkiG9w0BCQEWFUNyYWlnLlJ1c3NlbGxAU3VuLkNPTTCC ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMXXgEAm88nu8cFbxXSWqTq+GaYpCx/0QSom 8kBbVxpJIURuO4ErLDupeXu6y9+5e7ZKLbeSQE5xbfYPcQR/IhqmYKy5YqRcuzPXREBj2zKEkZph pNXWpHgMdx9W8dq0Cu2i9Ux/S6c2MuEHrP6gfGGll+b/mzLoO280QHTuE4pcpKntRnwZdGxQ/5l8 IL+eLP+jpJAbYW9C+KNKofZtS6V6R0uzlqTOsEdZvwxZQ4mmPgHoz1+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