|
范例程序参见附录二。
1.2.3. 如何执行数据库动态操作
对输出和输入参数变化的SQL语句进行处理,例如:
Query query = con.query();
query << "select * from stock";
Result res = query.store();
cout << "Query: " << query.preview() << endl;
cout << "Records Found: " << res.size() << endl << endl;
cout << "Query Info:\n";
for (unsigned int i = 0; i < res.names().size(); i++) {
cout << setw(2) << i
<< setw(15) << res.names(i).c_str()
// this is the name of the field
<< setw(15) << res.types(i).sql_name()
// this is the SQL identifier name
// Result::types(unsigned int) returns a mysql_type_info which in many
// ways is like type_info except that it has additional sql type
// information in it. (with one of the methods being sql_name())
<< setw(20) << res.types(i).name()
// this is the C++ identifier name which most closely resembles
// the sql name (its is implementation defined and often not very readable)
<< endl;
}
范例程序参见附录三。
2. 其它说明 MySQL提供类似sqlplus的客户端登录工具mysql,可以方便的如sqlplus一样spool查询结果放入文本文件中。它还提供数据导出和导入工具,可以方便的导出数据文本文件和导入文本文件。当然网上也有较多的MySQL数据库图形化管理工具。
上一页 [1] [2] [3] 没有相关教程
|