資料庫程式設計第四章課後作業

2021-08-22 10:30:49 字數 1302 閱讀 8090

begin ;

set autocommit=1;

#第三題

update book set bcount=bcount-1

where bname = "紅樓夢";

update reader set lendnum = lendnum+1

where rname = "張無忌";

commit

#第四題

insert into penalty(rid,bid,pdata,ptype,amount)values(6,1,now(),1,4.6);

update boorrow set returndata=now()

where rid=6;

update reader set lendnum=lendnum-1

where rname="劉冰冰";

update book set bcount=bcount+1

where bname="西遊記";

commit;

rollback;

#第五題

create view administrators as

select b.bname as 圖書名稱,w.willdata as 歸還日期,r.rname as 讀者姓名 from book b

inner join boorrow w on w.nif = b.bid

inner join reader r on r.rid= w.rid

select * from administrators

create view readers as

select b.bname as 圖書名稱,b.bcount as 館存量,(b.bcount-(select count(nif) from boorrow)) as 可借閱的數量 from book b

create index title_index

on book (bname)

select * from readers

#第六題

#備份資料

mysqldump -u root -p test > c:\backup\books.sql

enter password:1234

#恢復資料

mysql -u root -p abc #匯出文字資訊

select * from reader into outfile 'd:\tb_reader.txt'

select * from book into outfile 'd:\tb_book.txt';

第四章課後作業

一 填空題 1 如類果類a繼承了b,那麼類a被稱為基 類,而類b被稱為派生 類。2 c 的兩種繼承為 單繼承 和多繼承 3 在預設情況下的繼承方式為私有繼承方式 4 從基類中公有派生乙個類時,基類的公有成員就成為派生類的公有 成員,而這個基類的保護成員就成為派生類的保護成員。5 c 提供了多繼承 機...

jQuery第四章課後作業

3.建立乙個物件student,表示乙個學生物件,要求如下。1 新增屬性 姓名,年齡和自我介紹。2 新增方法 輸出該學生的姓名,年齡和自我介紹。3 在頁面上顯示該方法輸出的資訊。4.建立乙個建構函式student,表示學生,要求如下。1 新增屬性 姓名,年齡和自我介紹。2 新增方法 在乙個p標籤中顯...

物件導向程式設計 第四章繼承,課後作業

1.設計bird類和fish類,都繼承自抽象類animal,實現其抽象方法info 並輸出他們的資訊。抽象父類 author lenovo abstract class animals 有參構造方法 public animals int age public int getage 抽象方法 publ...