SQLServer DML 資料操作語言語法

2021-07-22 18:03:53 字數 1094 閱讀 8943

————————select 查詢————————–

–查詢stuinfo表中的所有資料

select * from stuinfo

–查詢stuinfo 表中的列的資料

select stuid,stuname, stu*** from stuinfo

–查詢stuinfo表中某一列的資料

select stuid from stuinfo

————————insert 插入————————–

–對應插入

insert into stuinfo(stuid,stuname,stu***) values(1,』matos』,』男』)

–全部插入

insert into stuinfo values (1,』matx』,』男』)

————————update 更新————————–

update stuinfo set stuname=』傅園慧』 where stuid==1

–多個字段更新

update stuinfo set stuname=』傅園慧』,stu***=』女』 where stuid==1

–給某個欄位加5更新

update stuinfo set score=score+5 where stuid==1

————————delete 刪除 或者 truncate table————————–

delete from stuinfo where stuid=1

–刪除表中所有資料

truncate table stuinfo

————-select…into.. 插入多行資料————————–

—-將表stuinfo表中,女生的資訊插入到stuinf2中

select * into stuinfo2 from stuinfo

where stu***=』女』

————-insert into… select 一次插入多行資料————————–

insert into stuinfo2(stuname,stu***)

select stuname,stu*** from stuinfo

MyBatis批量插入 insert 資料操作

在程式中封裝了乙個list集合物件,然後需要把該集合中的實體插入到資料庫中,由於專案使用了spring mybatis的配置,所以打算使用mybatis批量插入,由於之前沒用過批量插入,在網上找了一些資料後最終實現了,把詳細過程貼出來。實體類trainrecord結構如下 1 2 3 4 5 6 7...

MongoDB 資料庫基操

認識mongodb 進入資料庫 mongo 退出 exit 庫,集合操作 顯示所有庫 show dbs 切換 建立資料庫 use 資料庫名稱 檢視所在庫 db 刪除庫 db.dropdatabase 顯示當前資料庫的集合 show collections 建立集合 db.createcollecti...

Redis資料庫基操

nosql簡介 不支援sql語法 讀寫效能高 靈活的資料模型 redis簡介 redis特性 1 redis支援資料的持久化,可以將記憶體中的資料儲存在磁碟中,重啟的時候可以再次載入進行使用。2 redis不僅僅支援簡單的key value型別的資料,同時還把value分為list,set,zset...