最近在修改代码时用到了一些数据库的操作,平时很少用,记个笔记:
(1)在表中插入新的字段
命令:ALTER TABLE 表名 ADD 要插入的字段 int default 0
实例:CString str="alter table tableInfo add num int defualt 0";
db.OpenSql(str);
(2)列数据的拷贝
命令:UPDATE 表名 SET 要拷贝的目标字段=要拷贝的数据字段
CString str="update tableInfo Set num = ID";
db.OpenSql(str);
(3)更新数据
CString str;
str.Format("update tableInfo Set num = %d, name='%s' , X=%f Where ID=%d "; count, "hello",0.15 ,0);
db.OpenSql(str);
(4)删除表
命令:drop table 表名
CString str="drop table tableInfo ";
db.OpenSql(str);