|
: 프로그램 내에서 DB를 만들때 인덱스 키를 어떻게 지정해요?
헬프의 내용을 붙여 넣기 한것입니다.
(Table1->CreateTable(); 의 헬프)
아래보시면 Table1->IndexDefs->Add(...)
도움이 될듯 합니다.
if (!Table1->Exists) // Don't overwrite an existing table
{
Table1->Active = false; // The Table component must not be active
// First, describe the type of table and give it a name
Table1->DatabaseName = "BCDEMOS";
Table1->TableType = ttParadox;
Table1->TableName = "CustInfo";
// Next, describe the fields in the table
Table1->FieldDefs->Clear();
TFieldDef *pNewDef = Table1->AddFieldDef();
pNewDef->Name = "Field1";
pNewDef->DataType = ftInteger;
pNewDef->Required = true;
pNewDef = Table1->AddFieldDef();
pNewDef->Name = "Field2";
pNewDef->DataType = ftString;
pNewDef->Size = 30;
// Next, describe any indexes
Table1->IndexDefs->Clear();
/* the 1st index has no name because it is a Paradox primary key */
Table1->IndexDefs->Add("","Field1", TIndexOptions() <<ixPrimary << ixUnique);
Table1->IndexDefs->Add("Fld2Index","Field2", TIndexOptions() << ixCaseInsensitive);
// Now that we have specified what we want, create the table
Table1->CreateTable();
}
|