插入更新删除数据

    技术2022-05-11  84

    插入数据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 newtabelfrom 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从别的表写条件,如两个表的关系了 


    最新回复(0)