插入更新刪除資料

2021-06-15 21:04:27 字數 809 閱讀 6254

插入資料

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從別的表寫條件,如兩個表的關係了

MySQL插入更新刪除資料

更新資料 select from person where id 10 update person set age 15,name liming where id 10 select from person where id 10 update person set info student whe...

MySQL 插入 更新 刪除資料

我們吧檢索單獨拉出去,是因為在jdbc中對於檢索的處理,和對於插入,更新,刪除操作是不同的。現在我們將分別介紹mysql的insert插入語句,update更新語句,delete刪除語句。part 1 插入資料 sql語句中,insert是用來插入的 或新增 插入或新增乙個行到資料庫中。有以下幾種方...

MySQL 插入 更新 刪除資料

插入 更新 刪除資料 一 插入資料 插入資料使用 insert 語句向表插入資料記錄,插入資料有四種方式,即為所有字段插入資料 為指定字段輸入資料 同時插入多條資料以及插入查詢結果。先建立乙個表,方便下面舉例 create table student stu id int 10 primary ke...