Sign in Join
Wiki copytemporary

Database field type/zh CN: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Database field type/zh CN

OldNewLine
1+## 概述
2+
3+FCL-DB数据库字段可以有不同的数据类型。在数据集中,可以使用这些类型的子集。不同的数据使用不同的数据类型。
4+
5+## 类型
6+
7+目前,有下字段类型定义:
8+
9+参见 [FCL 字段类型文档](http://lazarus-ccr.sourceforge.net/docs/fcl/db/tfieldtype.html)
10+
11+To do: 新增分配信息(例如,您可以使用.AsString)及以下的附加信息。
12+
13+| 类型 | 说明 |
14+|----|----|
15+| ftADT | ADT 值 |
16+| ftArray | 数组数据,代表 Interbase 6/Firebird 数组数据类型(简单的数组类型像varchar 或整型)。然而,SQLDB目前不支持数组数据类型。 |
17+| ftAutoInc | 自增整数值(4字节) |
18+| ftBCD | 二进制编码的十进制值(SQL的decimal和numeric类型) |
19+| ftBlob | 二进制大对象(BLOB),用于存储任意二进制数 |
20+| ftBoolean | 布尔值 |
21+| ftBytes | 字节值数组,固定大小 |
22+| ftCurrency | 货币数值,精确到小数点后4位 |
23+| ftCursor | 游标数据无大小) |
24+| ftDataSet | 数据集数据(blob),大概意思是存储整个数据集(可能实现主/详细表格) |
25+| ftDate | 日期值 |
26+| ftDateTime | 日期/时间(时间戳) |
27+| ftDBaseOle | Paradox OLE字段数据 |
28+| ftFMTBcd | 格式化的BCD(二进制编码的十进制)值 |
29+| ftFixedChar | 固定字符数组(字符串) |
30+| ftFixedWideChar | 定长字符日期(每个字符2个字节) |
31+| ftFloat | 浮点值(双) |
32+| ftFmtMemo | 格式化的memo数据(无大小) |
33+| ftGraphic | 图形数据(无大小) |
34+| ftGuid | GUID(Globally Unique Identifier全局唯一标识符)数据 |
35+| ftIDispatch | Dispatch data value |
36+| ftInteger | 整型(4字节,有符号) |
37+| ftInterface | 接口数据 |
38+| ftLargeint | 长整型(8字节) |
39+| ftMemo | 二进制文本数据(无大小) |
40+| ftOraBlob | Oracle BLOB 数据 |
41+| ftOraClob | Oracle CLOB 数据: 可以存储高达 4 GB 数据 [1](http://www.orafaq.com/wiki/CLOB) |
42+| ftParadoxOle | Paradox OLE字段类别(无大小) |
43+| ftReference | 参考数据 |
44+| ftSmallint | 短整型(1字节,有符号) |
45+| ftString | 字符串数据(ansistring) |
46+| ftTime | 时间值 |
47+| ftTimeStamp | 时间戳数据 |
48+| ftTypedBinary | 二进制类型数据(无大小) |
49+| ftUnknown | 未知数据类型 |
50+| ftVarBytes | 字节数组,可变大小(untyped) |
51+| ftVariant | Variant 数据 |
52+| ftWideMemo | 宽字符串 memo 类型 |
53+| ftWideString | 宽字符串(每字符占2字节) |
54+| ftWord | Word-sized value(2 bytes, unsigned) |
55+
56+## 大小,数据大小和Unicode
57+
58+请注意,对于字符串类型字段,大小指可存储的字符数目。 正如[[FPC Unicode support|FPC Unicode 支持]],FPC包括2.6只处理 **ANSI/ASCII** 单字节字符; 它不支持 Unicode/UTF8/UTF16/Unicodestring 字符。
59+
60+只读属性的 DataSize 表示以字节为单位的字段大小。
61+
62+如果使用多字节字符(如 UTF8 或 UTF16/Unicodestring 编码),DataSize和Size并不意味着相同。如果仅使用 ANSI/ASCII 字符, DataSize 和 Size 将相同。
63+
64+## 在数据集中定义类型
65+
66+*Todo: write me. Explain various ways of doing things (TFieldDef, TFields) and which dataset supports which methods.*
67+
68+## 赋值和取值
69+
70+一旦定义你的数据集字段,你就可以进行赋值取值操作,像这样的,假设你有一个 FTestDataset 的数据集:
71+
72+``` pascal
73+ FTestDataset.Open; // 打开进行查看/编辑/插入
74+ FTestDataset.Append;
75+ FTestDataset.Fieldbyname('YourFieldName').Asstring := 'This is my field data'; // 假设 YourFieldName 是 memo 字段
76+ FTestDataset.Post; // "提交"/保存更改记录到数据集
77+ writeln('YourFieldName has data:' + FTestDataset.Fieldbyname('YourFieldName').Asstring
78+ { 获取当前记录的字段值。因为我们还没有移动的记录,我们应该得到什么,我们刚刚进入 }
79+```
80+
81+为 text/memo 字段,使用AsString 方法。 为 date/time 字段,使用 AsDateTime 方法。 为 binary 字段,我想你可以使用 AsString 方法 - *但一定还有其他办法。*
82+
83+## 参见
84+
85+- [[Databases/zh CN|数据库]]
86+
87+---
88+*From the Free Pascal wiki, page "Database field type/zh CN", as it stood on 2020-02-12 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history