From: Date: April 6 2006 6:04am Subject: RE: getting table meta data (primary key, in this case) List-Archive: http://lists.mysql.com/internals/33499 Message-Id: <1144296244.30369.14.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-INdjs7aepsA4bHL3TiLy" --=-INdjs7aepsA4bHL3TiLy Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2006-04-05 at 11:28 -0700, Rick James wrote: > If I could use Perl, I would do... >=20 > 1. Get output from "SHOW CREATE TABLE foo"=20 > 2. foreach line: > 2a. if ($lin =3D~ m{^\s*PRIMARY KEY.*\((.*)\)}) > commalist of keys in the PK is in $1 > 2b. if ($lin =3D~ m{^\s*UNIQUE.*\((.*)\)}) > AND you don't already have the PK, > commalist of keys in the PK is in $1 >=20 but you'd query INFORMATION_SCHEMA in 5.0 and above though :) possibly have a look at the I_S code in sql_show.cc to see how it generates the table. --=20 Stewart Smith, Software Engineer MySQL AB, www.mysql.com Office: +14082136540 Ext: 6616 VoIP: 6616@stripped Mobile: +61 4 3 8844 332 Jumpstart your cluster: http://www.mysql.com/consulting/packaged/cluster.html --=-INdjs7aepsA4bHL3TiLy Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBENJMzKglWCUL+FDoRAtjJAKC+Yo0eg4N/tm8zFcJS7Z2PFMOMHQCfaQAW OklEahAXNS59DSQjwJ+nbfI= =i7PX -----END PGP SIGNATURE----- --=-INdjs7aepsA4bHL3TiLy--