怎么開發(fā)一款小程序優(yōu)化網(wǎng)站價格
一、 實驗?zāi)康?br /> (1) 掌握數(shù)據(jù)的插入(INSERT)、 修改(UPDATE) 和刪除(DELETE) 操作。
(2) 掌握不同類型的數(shù)據(jù)查詢(SELECT) 操作。
二、 實驗要求
(1) 利用 INSERT 語句向圖書銷售系統(tǒng)表中插入數(shù)據(jù)。
(2) 利用 UPDATE 語句修改圖書銷售系統(tǒng)表中的數(shù)據(jù)。
(3) 利用 DELETE 語句刪除圖書銷售系統(tǒng)表中的數(shù)據(jù)。
(4) 利用 SELECT 語句實現(xiàn)對圖書銷售系統(tǒng)數(shù)據(jù)的有條件查詢、 分組查詢、 連接查詢、 子查詢等。
三、 實驗內(nèi)容
(1) 以 bs 用戶登錄 BOOKSALES 數(shù)據(jù)庫, 將下列表中的數(shù)據(jù)插入到數(shù)據(jù)庫的相應(yīng)表中。
(2) 將 ISBN 為 978-7-121-18619-8 的圖書的零售價格(retail) 修改為 30。
(3) 將訂單號為 1000 的訂單的發(fā)貨日期修改為“2013-2-2”。
(4) 查詢 BOOKS 表中包含的所有圖書列表。
(5) 列出 BOOKS 表中有圖書類型非空的圖書書名。
(6) 列出 BOOKS 表中每本書的書名和出版日期。 對 pubdate 字段使用 Publication Date 列標(biāo)題。
(7) 列出 CUSTOMERS 表中每一個客戶的客戶號以及他們所在的地址。
(8) 創(chuàng)建一個包含各個出版社的名稱、 聯(lián)系人以及出版社電話號碼的列表。 其中, 聯(lián)系人的列在顯示的結(jié)果中重命名為 Contact Person。
(9) 查詢下達(dá)了訂單的每一個客戶的客戶號。
(10) 查詢 2013 年 3 月 1 日之后發(fā)貨的訂單。
(11) 查詢居住在北京或大連的客戶, 將結(jié)果按姓名的升序排列。
(12) 列出姓“王” 的作者編寫的所有圖書信息, 并將結(jié)果按姓名降序排序。
(13) 查詢“兒童” 類和“烹飪” 類的所有圖書。
(14) 查詢書名的第二個字母是“A”、 第四個字母是“N” 的圖書信息。
(15) 查詢電子工業(yè)出版社在 2012 年出版的所有“計算機(jī)” 類圖書的名稱。
(16) 查詢圖書名稱、 出版社名稱、 出版社聯(lián)系人的名稱、 EMAIL 和電話號碼。
(17)查詢當(dāng)前還沒有發(fā)貨的訂單信息及下達(dá)訂單的用戶名, 查詢結(jié)果按下達(dá)訂單日期排序。
(18) 查詢已經(jīng)購買了“計算機(jī)” 類圖書的所有人的客戶號和姓名。
(19) 查詢“王牧” 購買的圖書的 ISBN 以及書名。
(20) 查詢訂購圖書“Oracle 數(shù)據(jù)庫基礎(chǔ)” 的客戶將收到什么樣的禮品。
(21) 確定客戶“張揚” 訂購的圖書的作者。
(22) 查詢 CUSTOMERS 表中的每一個客戶所下達(dá)的訂單數(shù)量。
(23) 查詢價格低于同一種類中其它圖書的平均價格的圖書的信息。
(24) 查詢每個出版社出版圖書的平均價格、 最高價格、 最低價格。
(25) 統(tǒng)計每個客戶購買圖書的數(shù)量及總價錢。
(26) 查詢比 1 號訂單中圖書數(shù)量多的其它訂單信息。
(27) 查詢所以客戶及其訂購圖書的信息。
(28) 查詢沒有訂購任何圖書的客戶信息。
(29) 查詢訂購金額最高的客戶信息。
(30) 查詢名為“趙敏” 的客戶訂購圖書的訂單信息、 訂單明細(xì)。
四、問題解答及實驗結(jié)果
(1) 以 bs 用戶登錄 BOOKSALES 數(shù)據(jù)庫, 將下列表中的數(shù)據(jù)插入到數(shù)據(jù)庫的相應(yīng)表中。
SQL> create sequence customers_customer_id minvalue 1 nomaxvalue increment by 1 start with 1 nocache;
SQL> insert into customers values(customers_customer_id.nextval,‘王牧’,‘83823422’,‘Wangmu@sina.com’,‘北京’,‘110010’);
SQL> insert into customers values(customers_customer_id.nextval,‘李青’,‘83824566’,‘Liqing@sina.com’,‘大連’,‘116023’);
SQL> insert into publishers values(1,‘電子工業(yè)出版社’,‘張芳’,‘56231234’);
SQL> insert into publishers values(2,‘機(jī)械工業(yè)出版社’,‘孫翔’,‘89673456’);
SQL> insert into books values(‘978-7-121-18619-8’,‘文化基礎(chǔ)’,‘王瀾’,to_date(‘2010-1-1’,‘yyyy-mm-dd’),2,35,28,‘管理’);
SQL> insert into books values(‘978-7-122-18619-8’,‘Oracle’,‘孫風(fēng)棟’,to_date(‘2011-2-1’,‘yyyy-mm-dd’),1,40,32,‘計算機(jī)’);
SQL> insert into orders values(orders_order_id.nextval,3,to_date(‘2013-2-1’,‘yyyy-mm-dd’),to_date(‘2013-2-5’,‘yyyy-mm-dd’),‘大連’,‘116023’);
SQL> insert into orders values(orders_order_id.nextval,2,to_date(‘2013-3-1’,‘yyyy-mm-dd’),to_date(‘2013-3-1’,‘yyyy-mm-dd’),‘大連’,‘116023’);
SQL> insert into orderitem values(1000,1,‘978-7-121-18619-8’,5);
SQL> insert into orderitem values(1000,2,‘978-7-122-18619-8’,20);
SQL> Insert Into orderitem values(1001,1,‘978-7-121-18619-8’,15);
SQL> insert into promotion values(1,‘簽字筆’,100,150);
SQL> insert into promotion values(2,‘筆記本’,150,300);
SQL> insert into promotion values(3,‘保溫杯’,300,500);
(2) 將 ISBN 為 978-7-121-18619-8 的圖書的零售價格(retail) 修改為 30。
SQL> update books set retail=30 where isbn=‘978-7-121-18619-8’;
(3) 將訂單號為 1000 的訂單的發(fā)貨日期修改為“2013-2-2”。
SQL> update orders set shipdate=to_date(‘2013-2-2’,‘yyyy-mm-dd’) where order_id=1000;
(4) 查詢 BOOKS 表中包含的所有圖書列表。
SQL> select * from books;
(5) 列出 BOOKS 表中有圖書類型非空的圖書書名。
SQL> select title from books where category is not null;
(6) 列出 BOOKS 表中每本書的書名和出版日期。 對 pubdate 字段使用 Publication Date 列標(biāo)題。
SQL> select title,pubdate “Publication Date” from books;
(7) 列出 CUSTOMERS 表中每一個客戶的客戶號以及他們所在的地址。
SQL> select customer_id,address from customers;
(8) 創(chuàng)建一個包含各個出版社的名稱、 聯(lián)系人以及出版社電話號碼的列表。 其中, 聯(lián)系人的列在顯示的結(jié)果中重命名為 Contact Person。
SQL> select name,contact “Contact Person”,phone from publishers;
(9) 查詢下達(dá)了訂單的每一個客戶的客戶號。
SQL> select customer_id from orders where order_id is not null;
(10) 查詢 2013 年 3 月 1 日之后發(fā)貨的訂單。
SQL> select * from orders where shipdate > to_date(‘2013-3-1’,‘yyyy-mm-dd’);
(11) 查詢居住在北京或大連的客戶, 將結(jié)果按姓名的升序排列。
SQL> select * from customers where address=‘大連’ or address=‘北京’ order by name;
(12) 列出姓“王” 的作者編寫的所有圖書信息, 并將結(jié)果按姓名降序排序。
SQL> select * from books where author like ‘王%’ order by author;
(13) 查詢“兒童” 類和“烹飪” 類的所有圖書。
SQL> select * from books where category=‘兒童’ or category=‘烹飪’;
(14) 查詢書名的第二個字母是“A”、 第四個字母是“N” 的圖書信息。
SQL> select * from books where title like ‘_A_N%’;
(15) 查詢電子工業(yè)出版社在 2012 年出版的所有“計算機(jī)” 類圖書的名稱。
SQL> select title from books,publishers where books.publisher_id=publishers.publisher_id and name=‘電子工業(yè)出版社’ and pubdate>=to_date(‘2012-1-1’,‘YYYY -mm-dd’) and pubdate<=to_date(‘2013-1-1’,‘YYYY-mm-dd’);
(16) 查詢圖書名稱、 出版社名稱、 出版社聯(lián)系人的名稱、 EMAIL 和電話號碼。
SQL> select title,name,contact,phone from books,publishers where books.publisher_id=publishers.publisher_id;
(17)查詢當(dāng)前還沒有發(fā)貨的訂單信息及下達(dá)訂單的用戶名, 查詢結(jié)果按下達(dá)訂單日期排序。
SQL> select order_id,customers.name,orderdate,shipdate,shipaddress,shipaddress,shipcode from customers,orders where customers.customer_id=orders.customer_id and shipdate<=to_date(‘2013-3-1’,‘yyyy-mm-dd’) order by orderdate;
(18) 查詢已經(jīng)購買了“計算機(jī)” 類圖書的所有人的客戶號和姓名。
SQL> select customers.customer_id,customers.name from customers,orders,orderitem,books where customers.customer_id=orders.customer_id and orders.order_id=orderitem.r_id and orderitem.isbn=books.isbn and books.category=‘計算機(jī)’;
(19) 查詢“王牧” 購買的圖書的 ISBN 以及書名。
SQL> select books.isbn,books.title from customers,books,orders,orderitem where customers.customer_id=orders.customer_id and orders.order_id=orderitem.r_id and orderitem.isbn=books.isbn and customers.name=‘王牧’;
(20) 查詢訂購圖書“Oracle 數(shù)據(jù)庫基礎(chǔ)” 的客戶將收到什么樣的禮品。
SQL> select books.isbn,books.title from customers,books,orders,orderitem where customers.customer_id=orders.customer_id and orders.order_id=orderitem.r_id and orderitem.isbn=books.isbn and books.title=‘Oracle’;
(21) 確定客戶“張揚” 訂購的圖書的作者。
SQL> select order_id,customers.name,orderdate,shipdate,shipaddress,shipcode from customers,orders where customers.customer_id=orders.customer_id and shipdate<=to_date(‘2013-3-1’,‘yyyy-mm-dd’) order by orderdate;
(22) 查詢 CUSTOMERS 表中的每一個客戶所下達(dá)的訂單數(shù)量。
SQL> select * from customers where customer_id not in(select customer_id from orders);
(23) 查詢價格低于同一種類中其它圖書的平均價格的圖書的信息。
SQL> select category,min(retail),max(retail),avg(retail) from books group by category;
(24) 查詢每個出版社出版圖書的平均價格、 最高價格、 最低價格。
SQL> select category,min(retail),max(retail),avg(retail) from books group by category;
(25) 統(tǒng)計每個客戶購買圖書的數(shù)量及總價錢。
SQL> select orders.order_id,orders.customer_id,orderitem.quantity from orders,orderitem where quantity > (select quantity from orderitem where order_id=1001 and item=1);
(26) 查詢比 1 號訂單中圖書數(shù)量多的其它訂單信息。
SQL> select order_id,sum(quantity) from orderitem group by order_id
having sum(quantity) > (select sum(quantity) from orderitem group by order_id
having order_id=1000);
(27) 查詢所以客戶及其訂購圖書的信息。
SQL> select * from customers where customer_id not in(select customer_id from orders);
(28) 查詢沒有訂購任何圖書的客戶信息。
SQL> select * from customers where customer_id not in(select customer_id from orders);
(29) 查詢訂購金額最高的客戶信息。
SQL> select customers.customer_id,customers.name,customers.phone,customers.email,customers.address,customers.code from customers,orders,orderitem where customers.customer_id=orders.customer_id and orders.order_id=orderitem.order_id and orderitem.quantity=(select max(quantity) from orderitem);
(30) 查詢名為“趙敏” 的客戶訂購圖書的訂單信息、 訂單明細(xì)。
SQL> select * from orders,orderitem,customers where orders.customer_id=customers.customer_id and customers.name=‘趙敏’;
五、實驗體會與收獲
通過這個實驗,我深入理解和掌握SQL語句的使用,提高數(shù)據(jù)庫操作的能力。并且能夠熟練地使用SQL語句進(jìn)行數(shù)據(jù)庫操作。這個實驗對于學(xué)習(xí)數(shù)據(jù)庫管理和SQL語句的應(yīng)用非常有幫助。能夠幫助我更好地理解和掌握SQL語句的使用。