全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2131
推到 Plurk!
推到 Facebook!

用程式產生資料庫和表格要設定哪些東西才會讓寫入最快ㄋ

答題得分者是:tech_state
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-04-22 00:00:16 IP:61.216.xxx.xxx 未訂閱
請問:    小弟在程式裡面動態建立表格,還要設定那些東西才能讓寫入達到最快呢? 之前很多文章都提到要利用外部工具設定,是否這些設定,也可以寫在程式 裡面?(例如:控制 BLOCK SIZE 來決定資料庫的容量)    下面是目前的作法,是否要先設定別名...   >>>DatabaseName = ".\\db">TableName = "Test.db"; NewTable->FieldDefs->Add("Subject",ftString,100,true); NewTable->FieldDefs->Add("DateTime",ftDateTime,0,true); NewTable->IndexDefs->Add("","Subject", TIndexOptions() << ixPrimary << ixUnique); NewTable->CreateTable(); NewTable->Free();
tech_state
版主


發表:44
回覆:638
積分:641
註冊:2003-02-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-04-22 11:55:36 IP:61.221.xxx.xxx 未訂閱
怎麼樣最快我不知道 不過bruce0211版主提供的心得分享[Paradox 資料庫的極限] 這篇文章的確可以提昇速度 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=18760 至於設定別名 我的習慣是會先設定啦 我測試了一下 如果不設定別名而直接給路徑的話也可以
引言: NewTable->DatabaseName = ".\\db";
這行少了一個. 程式執行起來會有路徑的問題 應改為 NewTable->DatabaseName = "..\\db"; 發表人 - tech_state 於 2003/04/22 12:07:38
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-04-22 12:24:28 IP:218.170.xxx.xxx 未訂閱
感謝版主大人提供寶貴的資料給小弟    但素這個程式沒錯啦已經執行很多次ㄌ    NewTable->DatabaseName = ".\\db";    .\\db 是指目前目錄下的 db 子目錄 ..\\db 是指返回上一層目錄,而且跳到一個叫 db 的目錄     應該是誤會吧< > 小弟瞭解設定別名的方法,和一些用途,例如: 可以存取兩個不同目錄時就會用到 但是可否在程式內達到外掛工具的設定才是小弟真正想問的 ... < > 不過無論如何還是非常謝謝您 版主很累不好當,好好加油喔!~
tech_state
版主


發表:44
回覆:638
積分:641
註冊:2003-02-10

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-04-22 13:02:42 IP:61.221.xxx.xxx 未訂閱
引言: 可否在程式內達到外掛工具的設定
不知您指的是什麼
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-04-22 13:23:55 IP:218.170.xxx.xxx 未訂閱
如版主提到的 [Paradox 資料庫的極限] 這篇文章 控制 BLOCK SIZE 來決定資料庫的容量 這個 BLOCK SIZE 如何由程式設定?THX
BeautyGirl
一般會員


發表:1
回覆:7
積分:6
註冊:2003-04-11

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-04-22 14:17:20 IP:218.170.xxx.xxx 未訂閱
引言: 如版主提到的 [Paradox 資料庫的極限] 這篇文章 控制 BLOCK SIZE 來決定資料庫的容量 這個 BLOCK SIZE 如何由程式設定?THX
是不是可以由程式修改小妹沒有試過,但是 可以用這個元件 http://www.vclxx.org/DELPHI/D32FREE/PXREST.ZIP 或是搜尋註冊表(regedit)以 BLOCK SIZE 為關鍵字,就可以找到存放的地方作修改了
tech_state
版主


發表:44
回覆:638
積分:641
註冊:2003-02-10

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-04-22 18:12:24 IP:61.221.xxx.xxx 未訂閱
China Join, 您好 不知以下的程式是否是您所說的由程式修改 BLOCK SIZE     void __fastcall TForm1::BitBtn1Click(TObject *Sender) {    hDBIDb hDb ;    DBIResult dbResult ;    CRTblDesc TblDesc ;    FLDDesc pFDesc;    String OptData;    //Initialize the BDE    DbiInit(NULL);       //Open a Database    DbiOpenDatabase(DatabaseAlias,NULL,dbiREADONLY,dbiOPENSHARED,NULL,0,NULL,NULL,hDb); memset((void *) &TblDesc, 0, sizeof(CRTblDesc)); lstrcpy(TblDesc.szTblName, TableName); lstrcpy(TblDesc.szTblType, szPARADOX); OptData = "4096"; // BLOCK SIZE pFDesc.iOffset = 0; pFDesc.iLen = OptData.Length 1; lstrcpy(pFDesc.szName, "BLOCK SIZE"); TblDesc.iOptParams = 1; // Only one optional parameter TblDesc.pfldOptParams = &pFDesc; TblDesc.pOptData = &OptData[1]; dbResult = DbiDoRestructure(hDb, 1, &TblDesc, NULL, NULL, NULL, false); if(dbResult == DBIERR_NONE) ShowMessage("Success"); else ShowMessage("Failure"); //Close Database DbiCloseDatabase(hDb); } 藍色部分可根據您的需求修改 我只測試有先設定別名的部分 如果以上程式符合您的需求 不設別名 直接給路徑的部份就由您來修改囉 發表人 - tech_state 於 2003/04/22 18:16:30
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-04-22 19:16:27 IP:218.170.xxx.xxx 未訂閱
謝謝大家幫小弟的忙    這個問題小弟已經藉由修改 RegEdit 解決了,tech_state 版主提供的方法 小弟試著去執行,但是還是有一些問題    小弟資料庫存放在 程式目錄下的 db 子目錄 檔名是 aaa.db 修改程式如下    #include 〈BDE.hpp〉    void __fastcall TForm1::Button1Click(TObject *Sender) {   hDBIDb hDb ;   DBIResult dbResult ;   CRTblDesc TblDesc ;   FLDDesc pFDesc;   String OptData;   //Initialize the BDE   DbiInit(NULL);      //Open a Database   DbiOpenDatabase(".//db",NULL,dbiREADONLY,dbiOPENSHARED,NULL,0,NULL,NULL,hDb);      memset((void *) &TblDesc, 0, sizeof(CRTblDesc));   lstrcpy(TblDesc.szTblName,"aaa");   lstrcpy(TblDesc.szTblType, szPARADOX);   OptData = "4096"; // BLOCK SIZE   pFDesc.iOffset = 0;   pFDesc.iLen = OptData.Length + 1;//這裡怪怪ㄉ   lstrcpy(pFDesc.szName, "BLOCK SIZE");   TblDesc.iOptParams = 1; // Only one optional parameter   TblDesc.pfldOptParams = &pFDesc;   TblDesc.pOptData = &OptData[1];      dbResult = DbiDoRestructure(hDb, 1, &TblDesc, NULL, NULL, NULL, false);   if(dbResult == DBIERR_NONE)   ShowMessage("Success");   else   ShowMessage("Failure");   //Close Database   DbiCloseDatabase(hDb); }    錯誤訊息為:[C++ Error] Unit1.cpp(36): E2235 Member function must be called or its address taken    這一行好像有問題 pFDesc.iLen = OptData.Length + 1;    如果版主大人沒空的話,可否告訴小弟資料出處,小弟自行研究就好啦 ~ 非常謝謝你們的幫忙 
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-04-22 19:22:14 IP:218.170.xxx.xxx 未訂閱
版主大大一直麻煩您 可否將您設定別名那一段貼上來呢,可能是這邊出問題ㄉ THX
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-04-22 19:41:21 IP:218.170.xxx.xxx 未訂閱
小弟自行加入別名,結果也是錯一樣的地方  MyAlias="MyAlias">IsAlias(MyAlias)) Session->AddStandardAlias(MyAlias, ExtractFilePath(Application->ExeName) "DB", "PARADOX"); hDBIDb hDb ; DBIResult dbResult ; CRTblDesc TblDesc ; FLDDesc pFDesc; String OptData; //Initialize the BDE DbiInit(NULL); //Open a Database DbiOpenDatabase("MyAlias",NULL,dbiREADONLY,dbiOPENSHARED,NULL,0,NULL,NULL,hDb);
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#11 引用回覆 回覆 發表時間:2003-04-22 19:55:06 IP:218.170.xxx.xxx 未訂閱
原本程式是錯的,改成    pFDesc.iLen = OptData.Length() + 1;    就可以執行了,但是沒有結果,也就是 BLOCK SIZE 沒有被改  (原本用 >
tech_state
版主


發表:44
回覆:638
積分:641
註冊:2003-02-10

發送簡訊給我
#12 引用回覆 回覆 發表時間:2003-04-22 22:06:40 IP:203.204.xxx.xxx 未訂閱
引言: pFDesc.iLen = OptData.Length() 1;
China Join, 您好 sorry, 複製程式碼的時候沒有注意到 的確是要如此才對 我這個方式是針對特定DataBase的特定Table修改 BLOCK SIZE 是用bruce0211版主提供的心得分享中的文章修改的 還是您可以提供您之前用過的工具 讓我知道您的需求到底是什麼?? 發表人 - tech_state 於 2003/04/22 22:07:26
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#13 引用回覆 回覆 發表時間:2003-04-22 23:12:07 IP:218.170.xxx.xxx 未訂閱
小弟的需求很簡單,就是讓使用者可以決定他新增資料庫的最大容量,因為如果 BLOCK SIZE 越大,相對的檔案空間也越大,所以目的就是讓客戶決定他新增的這個資料庫容量的上限。 沒有其他工具,就只有用 用 BCB 內建的 BDE Administrator 來改的經驗,目前資料量還不夠多,所以沒有辦法實際驗證資料庫的上限,不過如果用 BDE Administrator 來看,這段程式並沒有作用,另外 BeautyGirl 大大提供的方法,的確可以用,因為改完之後 BDE Administrator 裡面的值也會跟著變,但如同版主大人所說,這段程式可能對特定 DataBase Table 有效,那就必需再實際驗證才能得知了。 在這邊可以看到 BDE Administrator -> Configuration -> Drivers -> Native -> ParaDox -> Block Size 說明如下: Paradox driver settings To configure the way Paradox tables are created, sorted, and handled, choose Paradox as the driver name on the Configuration page of the BDE Administrator or create or select a STANDARD alias on the Databases page that uses Paradox as the Default Driver. To change a setting, highlight the desired configuration parameter. Delete the old value and enter a new one in the appropriate text box. You can only change parameters WITHOUT bold labels. In the following table, Parameters lists all tracked parameters for the selected driver type, and their current settings. When the driver is first installed, all values are set to their defaults. Description briefly notes the purpose of the highlighted parameter. Parameter Description NET DIR The directory location of the Paradox network control file PDOXUSRS.NET. The active NET DIR parameter is stored in the Paradox section of the BDE configuration file and has precedence over any other NET DIR parameters that may be stored in older 16-bit configuration files, or in the System Init section of the current configuration file, or in the Registry. These other NET DIR entries will have no effect. To access a Paradox table on a network drive, the active NETDIR parameter in the Paradox section of the BDE configuration file must point to a network drive. VERSION Internal version number of the Paradox driver. TYPE Type of server to which this driver helps you connect. Can be SERVER (SQL server) or FILE (standard, file-based server). LANGDRIVER Language driver used to determine table sort order and character set. [available drivers]. US default: 'ascii' ANSI (DBWINUS0) BLOCK SIZE Size of disk blocks used to store Paradox table records, in multiples of 1024 bytes. Valid settings depend on the table format: Level 5 and 7 1024, 2048, 4096, 16384, and 32768 Level 3 and 4 1024, 2048, and 4096 Default: 2048 FILL FACTOR Percentage of current disk block which must be filled before Paradox will allocate another disk block for index files. Can be any integer ranging from 1 to 100. Default: 95 Note: Smaller values offer better performance but increase the size of indexes. Larger values give smaller index files but increase the time needed to create an index. LEVEL Type of table format used to create temporary Paradox tables. Level 7 Paradox for Windows 32-bit tables Level 5 Paradox 5.0 tables Level 4 STANDARD table format introduced in Paradox 4.0 Level 3 Compatible table format used by Paradox 3.5 and earlier versions. Default: Level 4. To use Blob fields, secondary indexes, and strict referential integrity, specify either Paradox level 4 or Paradox level 5 tables. You will probably want to use the lowest level possible in order to maximize backward compatibility. Choose Level 7 only If you need the advanced indexing features supported by that table format. STRICTINTEGRTY Specifies whether Paradox tables can be modified using applications that do not support referential integrity (such as, Paradox 4.0). For example, if TRUE you will be unable to change a table with referential integrity using Paradox 4.0; if FALSE, you can change the table, but you risk the integrity of your data. Default: TRUE.
tech_state
版主


發表:44
回覆:638
積分:641
註冊:2003-02-10

發送簡訊給我
#14 引用回覆 回覆 發表時間:2003-04-23 14:21:55 IP:61.221.xxx.xxx 未訂閱
引言: 小弟的需求很簡單,就是讓使用者可以決定他新增資料庫的最大容量,因為如果 BLOCK SIZE 越大,相對的檔案空間也越大,所以目的就是讓客戶決定他新增的這個資料庫容量的上限。 沒有其他工具,就只有用 用 BCB 內建的 BDE Administrator 來改的經驗,目前資料量還不夠多,所以沒有辦法實際驗證資料庫的上限,不過如果用 BDE Administrator 來看,這段程式並沒有作用,另外 BeautyGirl 大大提供的方法,的確可以用,因為改完之後 BDE Administrator 裡面的值也會跟著變,但如同版主大人所說,這段程式可能對特定 DataBase Table 有效,那就必需再實際驗證才能得知了。 在這邊可以看到 BDE Administrator -> Configuration -> Drivers -> Native -> ParaDox -> Block Size
China Join, 您好 用 BDE Administrator 修改 Block Size 後會出現訊息 請您對所有使用 BDE database 的 table 做 Restructure 所以基本上如果您只修改 BDE Administrator 的設定 對您之前已建立的 table 好像也沒有影響 所以我認為 如果您要使用者自己修改 Block Size 的話 可能已只能針對特定 database 的 table 如同對 table 做 pack 的動作一樣 如果您要針對特定 database 裡所有的 table 都重新設定 Block Size 的話 就只好做迴圈將 table 一個一個找出來修改 Block Size 然後再做 Restructure 記得不是只做 Block Size 的修改 而沒有做 Restructure 這樣是沒有用的喔 ============ 是非終日有 不聽自然無
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#15 引用回覆 回覆 發表時間:2003-04-23 15:32:14 IP:218.170.xxx.xxx 未訂閱
不好意思,版主大人所指的 Restructure 要如何作呢?    這個東西浪費您太多時間,小弟先把答題分數給妳ㄌ 
tech_state
版主


發表:44
回覆:638
積分:641
註冊:2003-02-10

發送簡訊給我
#16 引用回覆 回覆 發表時間:2003-04-23 15:59:21 IP:61.221.xxx.xxx 未訂閱
引言: 不好意思,版主大人所指的 Restructure 要如何作呢? 這個東西浪費您太多時間,小弟先把答題分數給妳ㄌ < face="Verdana, Arial, Helvetica"> China Join, 您好 如果是用 BDE Administrator 我也不知道怎麼做 在程式中可以用這個指令 DbiDoRestructure 做 Restructure 的動作 雖然您已做結案 但還是希望如果其他前輩先進有更好的方法的話 可以不吝指教 ============ 是非終日有 不聽自然無
China Join
中階會員


發表:81
回覆:242
積分:89
註冊:2003-03-12

發送簡訊給我
#17 引用回覆 回覆 發表時間:2003-04-23 16:27:12 IP:218.170.xxx.xxx 未訂閱
各位先進如果有這方面的經驗請提供給小弟,再次謝謝版主大人!
系統時間:2024-04-25 21:44:23
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!