您的位置:首页 > 数据库

插入更新删除数据

2007-02-09 15:10 405 查看
插入数据
insert into mytable (id,name,age) values (1,xxiang,23)

从别的表中数据插入到mytable中
insert into my(id,name,age)
select id,name,age from othertable

从别的表中数据插入到新的表中,新表未创建(就是数据库中没有这个表)
select Id,name,age
insert into newtabel
from mytable

更新数据
update mytable set name='xxiang2007' where age=24  //有条件
update mytable set name='xxiang2007'               //无条件,就是全部的数据
update mytable set name='xxiang2004' from newtable where id=10  //也可以用from从别的表写条件

删除数据
delete from mytable where name='xxiang2007'  //有条件
delete from mytable                          //无条件,就是全部的数据
truncate table mytable                       //删除全部数据
delete from mytable from newtable where id =10   //也可以用from从别的表写条件,如两个表的关系了
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息