freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

21天學通oracle課后答案解析[第三版](編輯修改稿)

2025-07-25 07:24 本頁面
 

【文章內容簡介】 _user_objects(object_type, objectCount),其數(shù)據來源于user_objects(owner, count(object_name)),也就是對每種object類型統(tǒng)計其object的數(shù)目。1)因為物化視圖中,不能使用子查詢。而關系視圖又被當做子查詢看待。因此,首先需要獲得user_objects的拷貝,創(chuàng)建一個新表tmp_user_objects。SQL create table tmp_user_objects as select * from user_objects。 Table created2)利用新表tmp_user_objects來創(chuàng)建物化視圖SQL create materialized view mv_user_objects 2 as 3 select object_type, count(object_name) object_count from tmp_user_objects 4 group by object_type 5 / Materialized view createdSQL select * from mv_user_objects。 OBJECT_TYPE OBJECT_COUNT FUNCTION 7INDEX 189INDEX PARTITION 31LOB 24PACKAGE 2PACKAGE BODY 2PROCEDURE 9QUEUE 4SEQUENCE 25SYNONYM 8TABLE 197TABLE PARTITION 27TRIGGER 16TYPE 4VIEW 16 15 rows selected3.分別啟用/禁用物化視圖mv_user_objects,來查看select object_type, count(object_name) object_count from tmp_user_objects的執(zhí)行效率。1)對于SQL語句,select owner, count(object_name) from dba_objects group by owner未啟用查詢重寫功能時,其執(zhí)行計劃如下所示:2)利用enable query rewrite選項,啟用物化視圖mv_user_objects的查詢重寫功能alter materialized view mv_user_objects enable query rewrite3)重新執(zhí)行相同的SQL語句,查看此時的執(zhí)行計劃第8章 函數(shù)與存儲過程1.創(chuàng)建一個函數(shù)is_date,并傳入一個字符串函數(shù)。如果該字符串可以轉換為“YYYYMMDD hh24:mi:ss”形式的日期,那么返回為真,否則返回為假。1)首先利用create or replace function命令創(chuàng)建is_date函數(shù)SQL create or replace function is_date (param varchar2) return varchar2 is 2 d date。 3 begin 4 d:=to_date (nvl (param, 39。 39。), 39。yyyymmdd hh24:mi:ss39。)。 5 return 39。TRUE39。 6 7 exception 8 when others then 9 return 39。FALSE39。 10 end。 11 / Function createdto_date (nvl (param, 39。 39。), 39。yyyymmdd hh24:mi:ss39。)用于將字符串參數(shù)param轉換為日期時間型,如果轉換成功,則返回“TRUE”;exception則用于處理異常情況,如果發(fā)生異常,函數(shù)將返回 “TRUE”。2)可以利用如下語句測試is_date()函數(shù)。SQL select is_date(39。201039。) as is_date from dual。 IS_DATEFALSESQL select is_date(39。abc39。) as is_date from dual。 IS_DATEFALSESQL select is_date(39。2010051239。) is_date from dual。 IS_DATETRUE2.創(chuàng)建一個存儲過程find_student,并傳入參數(shù)學生姓名(studentName),打印表students中所有同名的學生信息。如果未找到同名學生,那么打印“無名為xxx的學生”。1)利用如下SQL語句創(chuàng)建存儲過程find_studentSQL create or replace procedure find_student(studentName varchar2) 2 as 3 4 begin 5 declare student_count number。 6 begin 7 select count(*) into student_count from students where student_name=studentName。 8 if student_count0 then 9 (39。共找到39。 || student_count || 39。個名為39。 || studentName || 39。的學生!39。)。 10 else 11 (39。未找到名為39。 || studentName || 39。的學生!39。)。 12 end if。 13 end。 14 end。 15 / Procedure created2)嘗試查找名為“張三”的學生SQL exec find_student(39。張三39。)。 共找到3個名為張三的學生! PL/SQL procedure successfully pleted3)嘗試查找名為“李四”的學生SQL exec find_student(39。李四39。)。 未找到名為李四的學生! PL/SQL procedure successfully pleted3.利用PL/SQL Developer的Debug功能調試存儲過程find_student。1)在PL/SQL Developer的Procedures下,找到存儲過程find_student。2)在右鍵菜單中選擇【Test】3)在參數(shù)欄內填入要傳入的參數(shù),并單擊Debug按鈕或者按下F9。4)此時,調試步驟按鈕欄將變?yōu)榭捎?。從左至右依次為:Run(繼續(xù)執(zhí)行,直至程序結束,或者下一個斷點)Step into(進入存儲過程/函數(shù)內部)Step Over(執(zhí)行當前語句,在下一條語句處停止)Step out(跳出當前存儲過程/函數(shù))Run to next exception(執(zhí)行直至下次拋出異常)4)利用這5個按鈕,即可進行存儲過程的調試。第9章 游標1.聲明一個游標cu_sutdnet,并向該游標傳遞參數(shù)studentName,來獲得所有與參數(shù)同名的學生信息。對該游標依次執(zhí)行打開、獲取、關閉的步驟來依次打印獲得的學生信息。1)聲明帶有參數(shù)的游標時,應將參數(shù)列表置于小括號內declare cursor cu_student_id_name(studentName)2)聲明變量臨時存取學生姓名和學號 student_id %type。 student_name %type。 3)打開游標時,傳入參數(shù)studentNameopen cu_student_id_name(39。張三39。)。 4)獲取游標數(shù)據fetch cu_student_id_name into student_id, student_name。 5)循環(huán)打印學生信息while cu_student_id_name %found loop (student_id || 39。:39。 || student_name)。 fetch cu_student_id_name into student_id, student_name。 end loop。6)關閉游標close cu_student_id_name。 7)執(zhí)行結果如下SQL declare cursor cu_sutdnet(studentName in varchar2) is 2 select student_id, student_name 3 from students where student_name=studentName。 4 5 student_id %type。 6 student_name %type。 7 begin 8 open cu_sutdnet(39。張三39。)。 9 fetch cu_sutdnet into student_id, student_name。 10 11 while cu_sutdnet%found loop 12 (student_id || 39。:39。 || student_name)。 13 fetch cu_sutdnet into student_id, student_name。 14 end loop。 15 16 close cu_sutdnet。 17 end。 18 / 17:張三18:張三21:張三 PL/SQL procedure successfully pleted2.聲明一個名為studentname的變量,然后利用cursor for游標來實現(xiàn)習題1的功能。通過修改studentname的值,來模擬傳入參數(shù)功能。SQL begin 2 declare 3 studentname varchar2(20)。 4 begin 5 studentname := 39。張三39。 6 for student in (select * from students where student_name = studentname) loop 7 ( || 39。:39。 || 8 )。 9 end loop。 10 end。 11 end。 12 /17:張三18:張三21:張三通過修改studentname的值,可以查找特定學生名稱的所有信息。3.創(chuàng)建函數(shù)get_student_cursor,返回表students中的所有學生信息的集合1)利用如下SQL語句創(chuàng)建名為get_student_cursor的函數(shù)SQL create or replace function get_student_cursor 2 return SYS_REFCURSOR 3 is 4 student_cursor sys_refcursor。 5 begin 6 open student_cursor for select * from students。 7 return student_cursor。 8 end。 9 / Function created2)利用返回的游標類型,打印所有學生姓名SQL begin 2 declare student_cursor sys_refcursor。 3 student students%rowtype。 4 begin 5 student_
點擊復制文檔內容
外語相關推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1