-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Greg Matthews wrote:
All,

I'd like to be able to query MySql using the JDBC driver to determine which
tables have auto incremented columns.

In MSSQL I can retrieve data from the syscolumns and sysobjects tables to
find out which columns are IDENTITY columns, but have had no luck trying to
do something similar in MySql (4.05).

e.g.

select so.name, sc.name from syscolumns sc, sysobjects so where sc.autoval
is not null and so.xtype = 'U' and so.id = sc.id order by 1,2


I'm extending some J2EE app generator functionality, and so would like to be
able to scan a database without knowing beforehand (based on business
knowledge) which tables have auto incremented columns.

I've tried:

1. Going over the java.sql metadata functionality to see if I can query this
through the standard java.sql functions.

2. Searching the MySql manual

Any help much appreciated.

Greg.


sql, query
You can look for 'auto_increment' in the 'REMARKS' column that is in the ResultSet created by DatabaseMetaData.getColumns().

You could also just do a 'show columns from tablename' and look for 'auto_increment' in the 'Extra' field.

JDBC itself does not provide a way from DatabaseMetaData to determine auto-increment or identity columns directly, only from ResultSetMetaData :(

-Mark

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+DNZhtvXNTca6JD8RAsfxAKCKSFMa6oH+e3Z0DfkbEsd0dWixSgCgpwyt
ublIE8OpfEonCjayj1LMIsg=
=BZew
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to