隨筆-10  評(píng)論-10  文章-0  trackbacks-0

          ??? 今天在深入學(xué)習(xí)了數(shù)據(jù)庫(kù)方面的知識(shí)。感覺(jué)挺吃力。 今天發(fā)現(xiàn)很多理論的知識(shí)掌握很不牢固,真是很慚愧,今后還得繼續(xù)在理論上下工夫。再說(shuō)今天接觸的知識(shí)吧,今天老總深入講解了關(guān)于select查詢方法的使用,發(fā)現(xiàn)這個(gè)東西實(shí)在是太靈活了!目前的自己拿著一個(gè)小項(xiàng)目也無(wú)法找到下手的方向,這應(yīng)該就是極度缺乏經(jīng)驗(yàn)的表現(xiàn),今后還得多多練習(xí)才能有顯著的提高。關(guān)于select,我先是很無(wú)語(yǔ),確實(shí)是非常的靈活,就其中的連接一項(xiàng),就嗆得我要死,看來(lái)自己在這幾天還得多多看相關(guān)的資料多多做練習(xí)才行。希望在研究數(shù)據(jù)庫(kù)的同志們也加油,多看書(shū),多看看好的代碼,多去理解,這樣自己才能有提高。 最后,把今天在老總帶領(lǐng)下完成的關(guān)于電子書(shū)店數(shù)據(jù)庫(kù)系統(tǒng)的代碼放在這里,對(duì)于老手來(lái)說(shuō)非常的簡(jiǎn)單,望所有新手共勉!

          (該代碼沒(méi)有涉及insert into,其中數(shù)據(jù)可以根據(jù)實(shí)際情況添加)

          create table customers
          (customerID int primary key not null,
          customername varchar(20) not null);?

          create table books
          (bookid int primary key not null,
          booktitle varchar(50) not null,
          unitprice int not null
          );?

          create table orders
          (orderid int primary key not null,
          orderdate date default sysdate not null,
          customerid int not null,
          constraint fk_c foreign key (customerid) references customers(customerid)
          );?

          create table orderitems
          (OrderItemID int primary key not null,
          orderid int not null,
          bookid int not null,
          quantity int default '1' not null,
          constraint fk_b foreign key (bookid) references books(bookid), constraint fk_o? foreign key (orderid) references orders(orderid));?

          select c.customername as 客戶名稱(chēng), sum(b.unitprice * oi.quantity)
          from customers c
          left join orders o on c.customerid = o.customerid
          left join orderitems oi on o.orderid = oi.orderid
          left join books b on oi.bookid = b.bookid
          where to_char(o.orderdate,'yyyy') = to_char(sysdate,'yyyy')
          group by c.customername

          posted on 2006-11-07 21:50 細(xì)雨游風(fēng) 閱讀(262) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 娄底市| 云和县| 北川| 临湘市| 长宁县| 衡阳县| 方城县| 元氏县| 康定县| 姜堰市| 沙田区| 满洲里市| 万载县| 永兴县| 富顺县| 大方县| 巴南区| 衡阳县| 南康市| 启东市| 抚顺县| 阿拉善右旗| 健康| 万源市| 屏南县| 金坛市| 临夏县| 通江县| 宾阳县| 交口县| 武胜县| 大同市| 遂宁市| 浦东新区| 昆明市| 怀柔区| 讷河市| 鄢陵县| 乃东县| 扎鲁特旗| 南昌市|