五、其他的特色:
CREATE TABLE invoice (
invoice_id int(10) unsigned NOT NULL auto_increment,
invoice_no int(10) unsigned DEFAULT ’0’ NOT NULL,
payee char(40) DEFAULT ’’ NOT NULL,
PRIMARY KEY (invoice_id),
KEY payee (payee)
);
INSERT INTO invoice VALUES (1,100,’Company AB’);
INSERT INTO invoice VALUES (2,101,’Company CD’);
INSERT INTO invoice VALUES (3,102,’Company EF’);
因为 MySQL 没有办法使用记录号,所以我们必须建立主键。
就有了以下的目录结构:
这样,每个列出现在不同的文件行之中,文件树的结构如下:
/mountpoint/database/table/.table
和
/mountpoint/database/table/primary_key/.record
/mnt/mysql/mydata/invoice/.table
/mnt/mysql/mydata/invoice/1/.record
/mnt/mysql/mydata/invoice/1/invoice_id
/mnt/mysql/mydata/invoice/1/invoice_no
/mnt/mysql/mydata/invoice/1/payee
/mnt/mysql/mydata/invoice/2/.record
/mnt/mysql/mydata/invoice/2/invoice_id
/mnt/mysql/mydata/invoice/2/invoice_no
/mnt/mysql/mydata/invoice/2/payee
/mnt/mysql/mydata/invoice/3/.record
/mnt/mysql/mydata/invoice/3/invoice_id
/mnt/mysql/mydata/invoice/3/invoice_no
/mnt/mysql/mydata/invoice/3/payee
这些文件是隐含的,以防重复,主要用来方便地通过文该篇文章件
浏览器来查看。
/mountpoint/database/table/primary_key/.max
或者
/mnt/mysql/mydata/invoice/invoice_id/.max
或者指向
/mountpoint/database/table/field
和
/mnt/mysql/mydata/invoice/3
/mnt/mysql/mydata/.keys/
/mnt/mysql/mydata/.keys/invoice_id/
/mnt/mysql/mydata/.keys/payee/
还有一些隐藏文件提供键类型:
/mnt/mysql/mydata/.keys/invoice_id/.type
/mnt/mysql/mydata/.keys/payee/.type
另外还可以用索引来排序记录,如果读取下面的目录:
PHP 的readdir() 函数就以升序返回数据的符号连接。
/mountpoint/.version
/mountpoint/.last_insert_id
/mountpoint/.uptime
/mountpoint/database/.raid (0/1)
/mountpoint/database/.type (ISAM/MyISAM/HEAP/DBD)
/mountpoint/database/.tables
/mountpoint/database/table/.created
/mountpoint/database/table/.last_updated
/mountpoint/database/table/.last_checked
/mountpoint/database/table/.count