| efault ''''0'''',
parentInstanceid int(10) unsigned NOT NULL default ''''0'''',
dn tinyblob NOT NULL,
mocid int(10) unsigned NOT NULL default ''''0'''',
flag tinyblob NOT NULL,
fid tinyblob NOT NULL,
adminstate tinyint(3) unsigned default ''''1'''',
opstate tinyint(3) unsigned default ''''0'''',
usagestate tinyint(3) unsigned default ''''0'''',
alarmstate tinyint(3) unsigned default ''''0'''',
unknownstate tinyint(3) unsigned default ''''0'''',
attrdatlen int(10) unsigned default ''''0'''',
attrdat blob,
modidate timestamp NOT NULL,
PRIMARY KEY (instanceid),
KEY i_moinfo (parentInstanceid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
删除语句:
DELETE FROM moinfo
插入语句:
INSERT INTO moinfo(instanceid,parentInstanceid,\
dn,mocid,flag ,fid,attrdatlen,attrdat)values(?,?,?,?,?,?,?,?)
查询语句1(包括将结果写入文件42280254字节):
SELECT INSTANCEID,PARENTINSTANCEID,DN,MOCID,FLAG,FID,\
ATTRDATLEN,length(attrdat) AS ATTRDATLEN2,ATTRDAT \
FROM MOINFO WHERE PARENTINSTANCEID= ? ")
查询语句2:
SELECT COUNT(1) FROM moinfo;
对于10000条记录(每条记录4228字节)MySQL的处理时间(单位 秒)如下:
测试序号
删除语句
插入语句
查询语句1
查询语句2
1
117″
476″
37″
6.80″
2
114″
479″
30″
6.69″
3
114″
475″
29″
6.70″
4
117″
476″
30″
6.72″
5
113″
474″
30″
6.68″
1.2.C++ API
MySQL的C++开放包是基于标准模板函数库STL的MySQL接口工具。目前版本是1.7.9,由于我们使用的是VC只有1.7.1版本可以使用。C++API由于使用了STL容器所以编程较C API来得方便。
1.2.1. 如何执行数据定义语句
使用Query类可以方便地进行所有操作。例如:
Query query = connection.query(); // create a new query object
try { // ignore any errors here
// I hope to make this simpler soon
query.execute("drop table stock");
} catch (BadQuery er) {}
范例程序参见附录二。
1.2.2. 如何执行数据操作语句
对指定的stock表插入三条记录,例如:
query << "insert into %5:table values (%0q, %1q, %2, %3, %4q)";
query.parse();
// set up the template query I will use to insert the data. The
// parse method call is important as it is what lets the query
// know that this is a template and not a literal string
query.def["table"] = "stock";
// This is setting the parameter named table to stock.
query.execute ("Hamburger Buns", 56, 1.25, 1.1, "1998-04-26");
query.execute ("Hotdogs'''' Buns" ,65, 1.1 , 1.1, "1998-04-23");
query.execute ("Dinner Roles" , 75, .95, .97, "1998-05-25");
query.execute ("Allen Lee" , 87, 1.5, 1.75, "1998-09-04"); 上一页 [1] [2] [3] 下一页 |