繁体中文设为首页加入收藏快捷桌面

魔域数据库删除语句和插入语句方法

  • 作者: 兰花GM
  • 来源: lanhuamoyu
  • 时间: 2017-9-14
  • 评论:
  • 浏览:



o删除语句(delete)
delete语句主要被用来删除符合条件的数据库记录


 delete from tablename where condition;

 例如:删除所有cq_action表中type为502的记录:

Delete from cq_action where type=502;
练习:
将cq_itemtype表中,名字带“剑”字的物品全部删除。
Delete from cq_itemtype where name like ‘%剑%’;


o插入语句(insert):



oInsert插入语句主要是用于在数据库某一张表内插入新记录
 insert into table_name (column1,column2,….) values (value1,value2,….);
  
例如:在cq_passway表中插入一条记录:
Insert into cq_passway (id,mapid,passway_idx,passway_mapid,passway_mapportal) values (0013,1006,0000,1002,0005);
如果不需要匹配字段插入,上面一句可写为:
Insert into cq_passway values (0013,1005,0000,1002,0005);

练习



o往cq_task表的id,id_next,money,sex,team,metempsychosis字段中插入数值1000,1001,0,999,999,0

oInsert into cq_task (`id`,`id_next`,`money`,`sex`,`team`,`metempsychosis`) values (1000,1001,0,999,999,0);

o更新语句(update):

oUpdate语句主要用于更新一条数据库中已经存在的表记录的数据
o
   update table_name set column1=XXX(,column2=XXX) where condition;
例如:将数据库cq_npc表中,所有type为2的npc,mapid都改成1000,lookface都改成1002
Update cq_npc set mapid=1000,lookface=1002 where type=2
练习:将数据库cq_itemtype表中所有名字带“剑”字,req_sex为1的物品,price改成0,weight改成0:
Update cq_itemtype set weight=0,price=0 where name like ‘%剑%’ and req_sex=1;
o



网友评论吐槽
验证码点击显示验证码