Mysql table indexes
Mysql table indexes
Hi Guys,
How could I know the indexes of a mysql table has ?
How could I know the indexes of a mysql table has ?
- FranciscoA
- Posts: 1964
- Joined: Fri Jul 18, 2008 1:24 am
- Location: Chinandega, Nicaragua, C.A.
Re: Mysql table indexes
Try this way:
Regards.
Code: Select all
oVer := oServer:Query("SHOW INDEX FROM " + cTable + ";")
Francisco J. Alegría P.
Chinandega, Nicaragua.
Fwxh1204-MySql-TMySql
Chinandega, Nicaragua.
Fwxh1204-MySql-TMySql
- FranciscoA
- Posts: 1964
- Joined: Fri Jul 18, 2008 1:24 am
- Location: Chinandega, Nicaragua, C.A.
Re: Mysql table indexes
Otra manera:
Saludos.
Code: Select all
//Para una tabla
SELECT DISTINCT
TABLE_NAME,
INDEX_NAME
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_NAME = 'retalcal';
//Para todas las tablas de una BDD
SELECT DISTINCT
TABLE_NAME,
INDEX_NAME
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = 'fapsoftware';
Francisco J. Alegría P.
Chinandega, Nicaragua.
Fwxh1204-MySql-TMySql
Chinandega, Nicaragua.
Fwxh1204-MySql-TMySql
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Mysql table indexes
vilian wrote:Hi Guys,
How could I know the indexes of a mysql table has ?
Code: Select all
aIndexes := oCn:ListIndexes( cTable )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Mysql table indexes
Hi Mr. Rao,nageswaragunupudi wrote:vilian wrote:Hi Guys,
How could I know the indexes of a mysql table has ?Code: Select all
aIndexes := oCn:ListIndexes( cTable )
Is there any function to create index?
Regards,
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Mysql table indexes
No.Is there any function to create index?
Not exactly but this function automatically creates a primary key index:
Code: Select all
METHOD MakePrimaryKey( cTable, cCol )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Mysql table indexes
Hi Mr. Rao,nageswaragunupudi wrote:No.Is there any function to create index?
Not exactly but this function automatically creates a primary key index:Code: Select all
METHOD MakePrimaryKey( cTable, cCol )
Do you mean we don't need index other than a primary key? Wouldn't it be better to index the connection variables of detail tables and master table?
Regards,
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
Hakan ONEMLI
Harbour & VS 2019 & FWH 20.12
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Mysql table indexes
a) We need to create unique indexes for enforcing unique constraint for a column or set of columns. If we want to create unique constraint to a single column, we can either create while creating the table or later create a unique index by:Do you mean we don't need index other than a primary key?
Code: Select all
oCn:Execute( "CREATE UNIQUE INDEX cust_name_uidx ON cust( name )" )
Code: Select all
oCn:Execute( "CREATE INDEX ON employee___idx ON employee( _ )" )
We do it by creating foreign key relationships. Our library provides special features to deal with parent-child relationships and you can find samples in the samples folder as well in the forum if you search.Wouldn't it be better to index the connection variables of detail tables and master table?
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India