Subject Re: [Firebird-Java] jdbc driver issue
Author Mark Rotteveel
Pruteanu Dragos wrote:
> It is fine, we can deal this situation too ( using no catalog and no schema - null for bought ).
> I wanted to be sure about how this method works. We will pass null than to each other methods ( getTables(), getColumns(), getExportedKeys, etc. ).

> Could you also please review the 'alter statement...' list below ? It would be a great help since you know the best the right commands.

I'll only comment if there is something wrong or if there is additional
information. You might also want to consult the Interbase 6.0 Language
Reference and the Firebird 2.0 Language Referene Update (both available
on http://www.firebirdsql.org/index.php?op=doc)

Note: I saw that Roman already answered, but I already invested some
time in it, so here it is:

> Create View CREATE VIEW {name} AS {text}
> Create Primary Key ALTER TABLE {table} ADD CONSTRAINT {name} PRIMARY KEY( {columns} )
> Create Unique Index ALTER TABLE {table} ADD CONSTRAINT {name} UNIQUE( {columns} )
> Create Index CREATE INDEX {name} ON {table} ( {columns} )

Full specification is CREATE INDEX [UNIQUE] [ASC[ENDING] | DESC[ENDING]]
INDEX ON {table} ( {columns} )

> Create Column ALTER TABLE {table} ADD COLUMN {text}

Incorrect, should be:
ALTER TABLE {table} ADD {text}

> Create Sequence CREATE SEQUENCE {name} START WITH {text}

Incorrect, use CREATE SEQUENCE {name} to create it, and ALTER SEQUENCE
{name} RESTART WITH {new value} to give it another start value

> Create Constraint ALTER TABLE {table} ADD CONSTRAINT {name} ( {text} )
> Drop table DROP TABLE {name}
> Drop Column ALTER TABLE {table} DROP COLUMN {column}

Incorrect, should be:
ALTER TABLE {table} DROP {plep}

> Drop Index DROP INDEX {name}
> Drop view DROP VIEW {name}
> Drop Foreign Key ALTER TABLE {table} DROP CONSTRAINT {name}
> Drop Constraint ALTER TABLE {table} DROP CONSTRAINT {name}
> Drop Sequence DROP SEQUENCE {name}
> Change Column data type ALTER TABLE {table} MODIFY {column} {text}

Incorrect,
ALTER TABLE {table} ALTER {column} TYPE {type}
or
ALTER TABLE {table} ALTER COLUMN {column} TYPE {type}

> Change Index to Primary Key ALTER INDEX {name} PRIMARY KEY

Unsupported, use ALTER TABLE (drop index and recreate constraint)

> Change Index to Unique ALTER INDEX {name} UNIQUE

Unsupported, use DROP INDEX and CREATE INDEX

> Change Index to non-unique ALTER INDEX {name} NONUNIQUE

Unsupported, use DROP INDEX and CREATE INDEX

> Change Foreign Key action ALTER CONSTRAINT {name} ON DELETE {delete_action} ON UPDATE {update_action}

Unsupported (AFAIK), use ALTER TABLE (drop and recreate constraint)

> Rename Index RENAME INDEX {name} TO {newname}

Unsupported (or you have to use metadata 'hacking')

> Rename Foreign Key RENAME {name} TO {newname}

Unsupported (or you have to use metadata 'hacking')

> Rename Constraint ALTER TABLE {table} RENAME CONSTRAINT {name} TO {newname}

Unsupported (or you have to use metadata 'hacking')

> Set Table comment COMMENT ON TABLE {table} IS '{comment}'
> Set Column comment COMMENT ON COLUMN {table}.{name} IS '{comment}'
> Set Column mandatory ALTER TABLE {table} MODIFY {column} NOT NULL

Unsupported, only on creation

> Set Column unsigned ALTER TABLE {table} MODIFY {column} UNSIGNED

Unsupported

> Set Column autoincrement ALTER TABLE {table} MODIFY {column} AUTOINCREMENT

Unsupported, use a trigger in combination with a sequence

> Set Column default ALTER TABLE {table} MODIFY {column} DEFAULT {defo}

Incorrect,
ALTER TABLE {table} ALTER {column} SET DEFAULT {default}
or
ALTER TABLE {table} ALTER COLUMN {column} SET DEFAULT {default}

> Set Column check constraint ALTER TABLE {table} MODIFY {column} CONSTRAINT {name} CHECK ( {text} )

Incorrect, is:
ALTER TABLE {table} ADD CONSTRAINT {name} CHECK ( {text} )
or
ALTER TABLE {table} ADD CONSTRAINT {name} CHECK ( {text} )

> Set Column unnamed check constraint ALTER TABLE {table} MODIFY {column} CHECK ( {text} )

Incorrect, is:
ALTER TABLE {table} ADD CHECK ( {text} )
or
ALTER TABLE {table} ADD CHECK ( {text} )

> Set Column enumeration ALTER TABLE {table} MODIFY {column} ENUMERATION ( {text} )

Unsupported

> Unset Column mandatory ALTER TABLE {table} MODIFY {column} NULL

Unsupported, only on creation

> Unset Column unsigned ALTER TABLE {table} MODIFY {column} SIGNED

Unsupported

> Unset Column autoincrement ALTER TABLE {table} MODIFY {column} NOAUTOINCREMENT

Unsupported

> Unset Column default ALTER TABLE {table} MODIFY {column} DEFAULT null

Incorrect,
ALTER TABLE {table} ALTER {column} DROP DEFAULT
or
ALTER TABLE {table} ALTER COLUMN {column} DROP DEFAULT

> Unset Column check constraint ALTER TABLE {table} MODIFY {column} DROP CONSTRAINT {table}

Incorrect,
ALTER TABLE {table} DROP CONSTRAINT {constraint}

> Unset Column enumeration ALTER TABLE {table} MODIFY {column} NOENUMERATION

Unsupported

> default date function -> sysdate

Incorrect, is: current_date

> default time function -> systime

Incorrect, is: current_time

> date format -> dd-MMM-yy

I have no idea, maybe someone else can answer that.

> When connecting, we got this data types. Is this list correct ?
>
> <type name="BIGINT" java="-5" precision="NONE" />
> <type name="BLOB SUB_TYPE 0" java="-4" precision="NONE" />
> <type name="BLOB SUB_TYPE 1" java="-1" precision="NONE" />
> <type name="CHAR" java="1" precision="LENGTH" />
> <type name="NUMERIC" java="2" precision="DECIMAL" />
> <type name="DECIMAL" java="3" precision="PRECISION" />
> <type name="INTEGER" java="4" precision="NONE" />
> <type name="SMALLINT" java="5" precision="NONE" />
> <type name="FLOAT" java="6" precision="NONE" />
> <type name="DOUBLE PRECISION" java="8" precision="NONE" />
> <type name="VARCHAR" java="12" precision="LENGTH" />
> <type name="DATE" java="91" precision="NONE" />
> <type name="TIME" java="92" precision="NONE" />
> <type name="TIMESTAMP" java="93" precision="NONE" />
> <type name="BLOB SUB_TYPE <0 " java="2004" precision="NONE" />

As far as I know, the datatypes metadata returned by the driver is
correct, but Roman probably knows better.

--
Mark Rotteveel <Avalanche1979@...>