FireDAC 下的 Sqlite [3] - 获取数据库的基本信息


在空白窗体上添加: TFDConnection, TFDPhysSQLiteDriverLink, TFDGUIxWaitCursor, TMemo

procedure TForm1.FormCreate(Sender: TObject);
var
  List: TStrings;
  V: Variant;
begin
  FDConnection1.Open(‘DriverID=SQLite; Database=C:\Temp\FDDemo.sdb‘);

  List := TStringList.Create;

  FDConnection1.GetInfoReport(List);
  Memo1.Clear;
  Memo1.Lines.Add(‘==> 获取连接信息:‘);
  Memo1.Lines.AddStrings(List);

  FDConnection1.GetTableNames(‘‘, ‘‘, ‘‘, List);
  Memo1.Lines.Add(#13#10‘==> 获取数据库中的表名列表:‘);
  Memo1.Lines.AddStrings(List);

  FDConnection1.GetTableNames(‘‘, ‘‘, ‘‘, List, [], [tkView]);
  Memo1.Lines.Add(#13#10‘==> 获取数据库中的查询名列表:‘);
  Memo1.Lines.AddStrings(List);

  FDConnection1.GetFieldNames(‘‘, ‘‘, ‘Orders‘, ‘‘, List);
  Memo1.Lines.Add(#13#10‘==> 获取 Orders 表中的字段名列表:‘);
  Memo1.Lines.AddStrings(List);

  V := FDConnection1.ConnectionMetaDataIntf.GetTables([], [tkTable], ‘‘, ‘‘, ‘‘).Rows[0].GetData(0);
  Memo1.Lines.Add(#13#10‘==> 获取第一个表中第一列的第一个数据:‘);
  Memo1.Lines.Add(V);

  List.Free;
end;


{结果如下:}
{...............................................................
==> 获取连接信息:
================================
Connection definition parameters
================================
Name=Unnamed
DriverID=SQLite
Database=C:\Temp\FDDemo.sdb
================================
FireDAC info
================================
Tool = RAD Studio XE6
FireDAC = 10.0.1 (Build 69712)
Platform = Windows 32 bit
Defines = FireDAC_NOLOCALE_META;FireDAC_MONITOR
================================
Client info
================================
Loading driver SQLite ...
DLL = 
Client version = 3.8.3.1
Compile options = ENABLE_COLUMN_METADATA;ENABLE_FTS3;
  ENABLE_FTS3_PARENTHESIS;ENABLE_FTS4;ENABLE_RTREE;
  ENABLE_STAT4;HAS_CODEC;OMIT_AUTOINIT;
  OMIT_DEPRECATED;SYSTEM_MALLOC;TEMP_STORE=2;
  THREADSAFE=2
================================
Session info
================================
Current catalog = 
Current schema = 
Total changes = 0
Database encoding = UTF8
Encryption mode = 
Cache size = 10000

==> 获取数据库中的表名列表:
Categories
CustomerCustomerDemo
CustomerDemographics
Customers
Employees
EmployeeTerritories
FDQA_all_types
FDQA_ascii_types
FDQA_batch_test
FDQA_bcd
FDQA_blob
FDQA_Categories
FDQA_db_types
FDQA_details_autoinc
FDQA_FK_tab
FDQA_ForAsync
FDQA_identity_tab
FDQA_locktable
FDQA_map1
FDQA_map2
FDQA_map3
FDQA_map4
FDQA_master_autoinc
FDQA_Maxlength
FDQA_novalstable
FDQA_numbers
FDQA_OrderDetails
FDQA_parambind
FDQA_Products
FDQA_tabwithpk
FDQA_timestamp
FDQA_transtable
FDQA_V_Test
FDQA_WString
"Order Details"
Orders
Products
Region
Shippers
Suppliers
Territories

==> 获取数据库中的查询名列表:
FDQA_V_Test

==> 获取 Orders 表中的字段名列表:
OrderID
CustomerID
EmployeeID
OrderDate
RequiredDate
ShippedDate
ShipVia
Freight
ShipName
ShipAddress
ShipCity
ShipRegion
ShipPostalCode
ShipCountry

==> 获取第一个表中第一列的第一个数据:
1
...............................................................}


FireDAC 下的 Sqlite [3] - 获取数据库的基本信息,布布扣,bubuko.com

FireDAC 下的 Sqlite [3] - 获取数据库的基本信息

上一篇:LC 212. 单词搜索2


下一篇:Database Backup and Recovery Basics