共用方式為


文字檔案格式 (文字檔案驅動程式)

ODBC 文字驅動程式同時支援分隔和固定寬度文本檔。 文本檔是由選擇性的頭行和零個或多個文字行所組成。

雖然標頭行使用與文本檔中其他行相同的格式,但 ODBC Text 驅動程式會將標題行專案解譯為數據行名稱,而非數據。

分隔的文字行包含一或多個以分隔符分隔的數據值:逗號、索引標籤或自定義分隔符。 檔案中必須使用相同的分隔符。 Null 數據值是由數據列中的兩個分隔符表示,其中沒有任何數據。 分隔文字行中的字元字串可以用雙引號括住(“)。 在分隔值之前或之後,不會發生空白。

固定寬度文字行中每個數據項的寬度是在架構中指定。 Null 數據值會以空白表示。

數據表最多只能有 255 個字段。 功能變數名稱限制為 64 個字元,字段寬度限制為 32,766 個字元。 記錄限制為65,000個字節。

文本檔只能針對單一用戶開啟。 不支援多個使用者。

為程式設計人員撰寫的下列文法會定義 ODBC 文字驅動程式可讀取的文字檔案格式:

格式 代表
非斜體 必須輸入的字元,如下所示
斜體 字 在文法中其他地方定義的自變數
方括弧 ([]) 選擇性項目
大括弧 ({}) 互斥選項的清單
垂直線 (|) 分開互斥的選擇
省略號 (...) 可以重複一或多次的專案

文字檔案的格式為:

text-file ::=  
   [delimited-header-line] [delimited-text-line]... end-of-file |  
   [fixed-width-header-line] [fixed-width-text-line]... end-of-file  
delimited-header-line ::= delimited-text-line  
delimited-text-line ::=  
   blank-line |  
   delimited-data [delimiter delimited-data]... end-of-line  
fixed-width-header-line ::= fixed-width-text-line  
fixed-width-text-line ::=  
   blank-line |  
   fixed-width-data [fixed-width-data]... end-of-line  
end-of-file ::= <EOF>  
blank-line ::= end-of-line  
delimited-data ::= delimited-string | number | date | delimited-null  
fixed-width-data ::= fixed-width-string | number | date | fixed-width-null  

備註

固定寬度文本檔中每個數據行的寬度是在 Schema.ini 檔案中指定。

  
      end-of-line ::= <CR> | <LF> | <CR><LF>  
delimited-string ::= unquoted-string | quoted-stringunquoted-string ::= [character | digit] [character | digit | quote-character]...  
quoted-string ::=  
   quote-character  
   [character | digit | delimiter | end-of-line | embedded-quoted-string]...  
   quote-characterembedded-quoted-string ::=   quote-characterquote-character  
   [character | digit | delimiter | end-of-line]  
   quote-characterquote-characterfixed-width-string ::= [character | digit | delimiter | quote-character] ...  
character ::= any character except:  
   delimiterdigitend-of-fileend-of-linequote-characterdigit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  
delimiter ::= , | <TAB> |   
custom-delimitercustom-delimiter ::= any character except:  
   end-of-fileend-of-linequote-character  

備註

自定義分隔文本檔中的分隔符是在 Schema.ini 檔案中指定。

quote-character ::= "  
number ::= exact-number | approximate-number  
exact-number ::= [+ | -] {unsigned-integer[.unsigned-integer] |  
   unsigned-integer. |  
   .unsigned-integer}  
approximate-number ::= exact-number{e | E}[+ | -]unsigned-integer  
unsigned-integer ::= {digit}...  
date ::=  
   mm date-separator dd date-separator yy |  
   mmm date-separator dd date-separator yy |  
   dd date-separator mmm date-separator yy |  
   yyyy date-separator mm date-separator dd |  
   yyyy date-separator mmm date-separator dd  
mm ::= digit [digit]  
dd ::= digit [digit]  
yy ::= digit digit  
yyyy ::= digit digit digit digit  
mmm ::= Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec  
date-separator ::= - | / | .  
delimited-null ::=  

備註

對於分隔的檔案,NULL 是由兩個分隔符之間的數據所表示。

fixed-width-null ::= <SPACE>...  

備註

如果是固定寬度的檔案,NULL 會以空格表示。