1:插入資料
2:修改資料
3:刪除資料
4: 檢視:
建立檢視
刪除檢視
查詢檢視
格式:insert into + 表名 + values + 常量
例1:將乙個新學生元組(學號:200215128;姓名:陳冬;性別:男;所在系:is;年齡:18歲)插入到 student表中。
insert
into student(sno, sname, s***, sdept, sage)
values
('200215128'
,'陳東'
,'male'
,'is',18
);
格式:update + 表名 + set + … + where + …
例2:將學生200215121的年齡改為22歲
update student
set sage =
22where sno =
'200215121'
例3:將所有學生的年齡增加1歲
update student
set sage = sage+
1帶子查詢的修改語句
例4:將電腦科學系全體學生的成績置零
update sc
set grade =
'0'where sno in
(select sno
from student
where student.sno = sc.sno and sdept =
'cs'
)
格式:delete from + 表名 + where
例5:刪除電腦科學系所有學生的選課記錄
delete
from sc
where sno =
(select sno
from student
where sdept =
'cs'
and sc.sno = student.sno
)
語法:create view + 檢視名 + as + 子查詢(select)
例1:建立資訊系學生的檢視
create
view is_student
asselect sno,sname,sage
from student
where sdept =
'is'
例2:建立資訊系學生的檢視,並要求進行修改和插入操作時仍需保證該檢視只有資訊系的學生
create
view is_student
asselect sno,sname,sage
from student
where sdept =
'is'
with
check
option
基於多個基表的檢視例3:建立資訊系選修了1號課程的學生檢視
create
view is_stu_1(sno, sname, grade)
asselect student.sno, sname, grade
from student,sc
where student.sno = sc.sno and sdept =
'is'
and sc.cno =
'1'
基於檢視的檢視例4: 建立資訊系選修了1號課程且成績在90分以上的學生的檢視 (基於 is_stu_1 檢視)
create
view is_s2
asselect sno,sname,grade
from is_stu_1
where grade >
90
drop
view is_s2
…待更 mysql資料庫各項引數查詢
1.qps show global status like question 2.tps show global status like com commit show global status like com roolback 3.執行緒連線數 show global status like ...
Mongo資料庫操作(三)
開通黃鑽 建立資料庫 use 如何什麼都不幹的話 會被刪除 檢視所有的資料 show dbs 給指定資料庫中新增資料 db.persons.insert 查詢資料庫中所有文件 show collections 查詢指定文件的資料 db.documentname find 查詢第一條資料 db.doc...
SQL 資料庫的操作(三)
sql 裡的case的作用 用於計算條件列表的表示式,並返回可能的結果之一。sql 的case 型別於程式語言裡的 if esle if else 或者 switch,但它不用於控制sql程式的執行流程,而是作為列的邏輯使用。語法 case input expression when when ex...