DBX driver for Postgres -> GetIndexNames
DBX driver for Postgres -> GetIndexNames
Hi;
I can't get index list for the database tables using TSQL.Connecton.GetIndexNames; it always returns an empty list. For example:
S := TStringList.Create;
Con.GetIndexNames('T1', SL);
I tested to get the list of table names with TSQL.Connecton.GetTableNames and it works fine.
Any help will be appreciated.
Regards,
Dany
I can't get index list for the database tables using TSQL.Connecton.GetIndexNames; it always returns an empty list. For example:
S := TStringList.Create;
Con.GetIndexNames('T1', SL);
I tested to get the list of table names with TSQL.Connecton.GetTableNames and it works fine.
Any help will be appreciated.
Regards,
Dany
GetIndexNames does not support lowercase table names for the Firebird driver and uppercase table names for the PostgreSQL driver.
The following query is used in PostgreSQL driver to get indexes. You can execute it yourself.
The following query is used in PostgreSQL driver to get indexes. You can execute it yourself.
Code: Select all
SELECT
n.nspname AS TABLE_SCHEMA, t.relname AS TABLE_NAME,
n.nspname AS INDEX_SCHEMA, c.relname AS INDEX_NAME,
a.attname AS COLUMN_NAME, a.attnum AS COLUMN_POSITION,
i.indisunique AS UNIQUE
FROM pg_index i
INNER JOIN pg_class c ON c.oid = i.indexrelid
INNER JOIN pg_class t ON t.oid = i.indrelid
INNER JOIN pg_namespace n ON n.oid = t.relnamespace
INNER JOIN pg_attribute a ON a.attrelid = i.indrelid and a.attnum = any (i.indkey)
WHERE
n.nspname = 'public' AND t.relname = 'T1'
ORDER BY n.nspname, t.relname, c.relname, a.attnum