FDMetaInfoQuery

http://docs.embarcadero.com/products/rad_studio/firedac/frames.html

http://docwiki.embarcadero.com/RADStudio/XE7/en/Metadata_Structure_(FireDAC)

FireDAC 查询数据库表、存储过程、字段信息等

MetaInfoKind属性有17种类型,获取数据库名称、表、字段、主键等信息。强大强大,不用写sql语句

mkNone
mkCatalogs
mkSchemas
mkTables
mkTableFields
mkIndexes
mkIndexFields
mkPrimaryKey
mkPrimaryKeyFields
mkForeignKeys
mkForeignKeyFields
mkPackages
mkProcs
mkProcArgs
mkGenerators
mkResultSetFields
mkTableTypeFields

FDMetaInfoQuery1->MetaInfoKind = mkTables;
 FDMetaInfoQuery1->Open();

FDMetaInfoQuery1->MetaInfoKind = mkTableFields;
 FDMetaInfoQuery1->Open(edtTableName->Text);

FDMetaInfoQuery1->MetaInfoKind = mkPrimaryKey;
 FDMetaInfoQuery1->Open(edtTableName->Text);

FDMetaInfoQuery1->MetaInfoKind = mkPrimaryKeyFields;
 FDMetaInfoQuery1->Open(edtTableName->Text,PKName); ?? 怎么赋值参数

AMIQ.CatalogName := edtCatalog.Text;
  AMIQ.SchemaName := edtSchema.Text;
  AMIQ.ObjectScopes := os;
  AMIQ.TableKinds := tk;

miIndexFields.CatalogName := FixName(miIndexes.FieldByName('CATALOG_NAME').AsString);
  miIndexFields.SchemaName := FixName(miIndexes.FieldByName('SCHEMA_NAME').AsString);
  miIndexFields.BaseObjectName := FixName(miIndexes.FieldByName('TABLE_NAME').AsString);
  miIndexFields.ObjectName := FixName(miIndexes.FieldByName('INDEX_NAME').AsString);
  miIndexFields.Open;

TFDConnection.GetTableNames('', '', '', lbxTables.Items);

TFDConnection.GetFieldNames('', '', Items[ItemIndex], '', lbxFields.Items);
TFDConnection.GetKeyFieldNames('', '', Items[ItemIndex], '', lbxKeyFields.Items);

05-12 13:58