db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Douglas Granzotto (Infoarte)" <dgranzo...@infoarte.trix.net>
Subject Re: Plataform.getAlterTablesSql results
Date Fri, 16 Jun 2006 12:00:10 GMT

----- Original Message -----
From: "Thomas Dudziak" <tomdzk@gmail.com>
To: <ddlutils-user@db.apache.org>
Sent: Wednesday, June 14, 2006 7:23 PM
Subject: Re: Plataform.getAlterTablesSql results


> On 6/14/06, Douglas Granzotto (Infoarte) <dgranzotto@infoarte.trix.net>
wrote:
>
> > Yes, I got the sources on 06/08/2006.
> > The FirebirdBuider.java class is ok.
> > The script generated by plataform.getAlterTablesSql(Database desiredDb,
> > boolean doDrops, boolean modifyColumns, boolean continueOnError)  works
> > well.
> > The only problem are these lines, that I think are unnecessary.
>
> DdlUtils will rebuild the table if the changes cannot be done via
> specific SQL commands. In your case, I guess that DdlUtils detected
> not only the column addition but also another change that cannot be
> handled via a specific SQL statement.
> Since the generated SQL does not contain the original table
> definition, its hard to say what the change was that lead to the full
> table rebuild. Could you perhaps post the SQL for creating the
> original table ?
>
> Tom
>

Original Table:

CREATE TABLE "IPI" (
  "IPICOD"  VARCHAR(2) NOT NULL,
  "IPIDESC"  VARCHAR(30),
  "TIPO"  INTEGER,
  "VERSAO"  INTEGER,
 PRIMARY KEY ("IPICOD"));
CREATE INDEX "IX_IPI_1" ON "IPI"("IPIDESC");

New Table:

CREATE TABLE "IPI" (
  "IPICOD"  VARCHAR(2) NOT NULL,
  "IPIDESC"  VARCHAR(30),
  "TIPO"  INTEGER,
  "CLASSFISCAL"  VARCHAR(12),
  "VERSAO"  INTEGER,
CONSTRAINT "PK_IPI" PRIMARY KEY ("IPICOD"));
CREATE INDEX "IX_IPI_1" ON "IPI"("IPIDESC");


SQL script generated by getAlterTablesSql:

ALTER TABLE IPI
    ADD CLASSFISCAL VARCHAR(12);

ALTER TABLE IPI
    ALTER CLASSFISCAL POSITION 4;

CREATE TABLE IPI_
(
    IPICOD VARCHAR(2) NOT NULL,
    IPIDESC VARCHAR(30),
    TIPO INTEGER,
    CLASSFISCAL VARCHAR(12),
    VERSAO INTEGER,
    PRIMARY KEY (IPICOD)
);

INSERT INTO IPI_ (CLASSFISCAL,IPICOD,IPIDESC,TIPO,VERSAO) SELECT
CLASSFISCAL,IPICOD,IPIDESC,TIPO,VERSAO FROM IPI;

DROP TABLE IPI;

CREATE TABLE IPI
(
    IPICOD VARCHAR(2) NOT NULL,
    IPIDESC VARCHAR(30),
    TIPO INTEGER,
    CLASSFISCAL VARCHAR(12),
    VERSAO INTEGER,
    PRIMARY KEY (IPICOD)
);

CREATE INDEX IX_IPI_1 ON IPI (IPIDESC);

INSERT INTO IPI (IPICOD,IPIDESC,TIPO,CLASSFISCAL,VERSAO) SELECT
IPICOD,IPIDESC,TIPO,CLASSFISCAL,VERSAO FROM IPI_;

DROP TABLE IPI_;



Mime
View raw message