【正文】
escape 39。, 340000, 39。1)同時(shí)使用rtrim()和ltrim()函數(shù),刪除字符串“000123456000”中的“0”SQL select ltrim(rtrim(39。Jerry39。data39。1)利用create table命令創(chuàng)建數(shù)據(jù)表test_data,并向其中插入測(cè)試數(shù)據(jù)SQL create table test_data(id number, name varchar2(20), Name varchar(20), name varchar2(20))。SQL create user bill identified by abc123 。User created.2)為mike賦予最基本的權(quán)限connect和create sessionSQL grant connect, create session to mike。嘗試?yán)眯薷膶傩詉ncrement by。SQL select from dual。 end if。 Commit plete4)驗(yàn)證兩個(gè)表中的數(shù)據(jù)是否一致SQL select * from products。)。 11 end。 || 8 )。)。 student_name %type。 13 end。如果未找到同名學(xué)生,那么打印“無名為xxx的學(xué)生”。 11 / Function createdto_date (nvl (param, 39。SQL create table tmp_user_objects as select * from user_objects。2)向表country中添加country_id為1的信息。SQL alter table customers drop primary key cascade。 Commit plete3)利用exp命令備份該表C:\exp system/abc123//(test_bak) file=39。 4 end loop。Export: Release Production on 星期三 7月 13 00:06:22 2011Copyright (c) 1982, 2004, Oracle. All rights reserved.Connected to: Oracle Database 10g Enterprise Edition Release ProductionWith the Partitioning, OLAP and Data Mining optionsExport done in ZHS16GBK character set and AL16UTF16 NCHAR character setAbout to export specified tables via Conventional Path .... . exporting table USERS 2 rows exportedExport terminated successfully without warnings.3)將d:\C:\imp system/abc123//(users) file=39。1 row created.5)利用表lob_source中的description信息,更新表lob_dest中的description信息。2.在對(duì)數(shù)據(jù)庫(kù)進(jìn)行重要操作時(shí),首先應(yīng)該確認(rèn)數(shù)據(jù)庫(kù)身份,以免在其他數(shù)據(jù)庫(kù)上進(jìn)行操作。嘗試?yán)脭?shù)據(jù)庫(kù)ORCL的TNS描述直接登錄數(shù)據(jù)庫(kù)。利用sqlplus+TNS配置登錄數(shù)據(jù)庫(kù)的命令如下所示:sqlplus sys/abc123(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl))) as sysdba登錄成功的界面如下所示:2.EZConnect是EasyConnect的簡(jiǎn)稱。嘗試?yán)肧QL Plus顯示數(shù)據(jù)庫(kù)實(shí)例名稱。SQL update lob_dest set description = (select description from lob_source source where = )。d:/39。 5 mit。d:/39。 Table altered4)重新創(chuàng)建基于列customer_id的主鍵。SQL insert into country values(1, 39。 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。 39。1)利用如下SQL語(yǔ)句創(chuàng)建存儲(chǔ)過程find_studentSQL create or replace procedure find_student(studentName varchar2) 2 as 3 4 begin 5 declare student_count number。 14 end。 3)打開游標(biāo)時(shí),傳入?yún)?shù)studentNameopen cu_student_id_name(39。 9 fetch cu_sutdnet into student_id, student_name。 9 end loop。 12 end。 1 row inserted SQL mit。 PRODUCT_ID PRODUCT_NAME 1 海爾冰箱 2 格力中央空調(diào) 3 戴爾電腦 SQL select * from popular_products。 end。 NEXTVAL 53)SQL select from dual。1)查看此時(shí)序列的nextval屬性的值SQL select from dual。Grant succeeded.3)利用用戶mike重新登錄數(shù)據(jù)庫(kù)4)利用用戶mike嘗試創(chuàng)建數(shù)據(jù)表SQL create table mike_test(id number)。User created.SQL grant connect, create session to bill。Table created.SQL insert into test_data values(1, 39。, 39。)。00012345600039。12%39。\39。%\%39。老板煙機(jī)39。嘗試?yán)盟鼈兎謩e刪除字符串“000123456000”中的“0”。Tomamp。, 39。第13章 Oracle數(shù)據(jù)類型1.在數(shù)據(jù)庫(kù)中創(chuàng)建表test_data(id number, name varchar(20), “Name” varchar2(20), “name” varchar2(20)),并查詢表中數(shù)據(jù)。1)在當(dāng)前狀態(tài)下,利用用戶system創(chuàng)建新的用戶bill,并為其分配connect, create session權(quán)限,以及在表空間users上10M的配額。1)創(chuàng)建用戶mikeSQL create user mike identified by abc123。這是因?yàn)樵撔蛄杏锌赡鼙黄渌瘮?shù)/存儲(chǔ)過程調(diào)用,刪除——重建之后,還需要重新測(cè)試那些函數(shù)和存儲(chǔ)過程是否能夠成功編譯,增加了開發(fā)者的工作量。 Sequence created2)序列seq_test創(chuàng)建成功之后, with屬性的值。)。 1 row updatedSQL mit。戴爾電腦39。 10 end loop。:39。張三39。1)聲明帶有參數(shù)的游標(biāo)時(shí),應(yīng)將參數(shù)列表置于小括號(hào)內(nèi)declare cursor cu_student_id_name(studentName)2)聲明變量臨時(shí)存取學(xué)生姓名和學(xué)號(hào) student_id %type。 12 end if。 IS_DATETRUE2.創(chuàng)建一個(gè)存儲(chǔ)過程find_student,并傳入?yún)?shù)學(xué)生姓名(studentName),打印表students中所有同名的學(xué)生信息。 10 end。因此,首先需要獲得user_objects的拷貝,創(chuàng)建一個(gè)新表tmp_user_objects。, 1) ORA02291: integrity constraint () violated parent key not found由于表country中并不存在country_id為1的值,因此,將導(dǎo)致添加失敗。 alter table customers drop primary key ORA02273: this unique/primary key is referenced by some foreign keys3)表customers中的主鍵與其他表的外鍵關(guān)聯(lián),可以利用cascade選項(xiàng)來刪除關(guān)聯(lián)約束。 6 / PL/SQL procedure successfully pletedSQL mit。)。d:/39。Table created.4)向測(cè)試表lob_dest中插入測(cè)試數(shù)據(jù),但是不包含clob類型的description列SQL insert into lob_dest(id) values(1)。利用SQL Plus登錄數(shù)據(jù)庫(kù):C:\sqlplus / as sysdbaSQL*Plus: Release Production on 星期日 7月 10 18:43:50 2011Copyright (c) 1982, 2004, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release ProductionWith the Partitioning, OLAP and Data Mining optionsSQL在控制臺(tái)上打印出的信息。此時(shí),可以利用將DNS描述直接作為參數(shù)傳遞給客戶端軟件的方式來登錄數(shù)據(jù)庫(kù),從而不再使用TNS配置文件。利用EZConnect可以在客戶端以IP+SID的方式登錄數(shù)據(jù)。1)利用SQL Plus登錄數(shù)據(jù)庫(kù):C:\sqlplus / as sysdbaSQL*Plus: Release Production on 星期日 7月 10 18:43:50 2011Copyright (c) 1982, 2004, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release ProductionWith the Partitioning, OLAP and Data Mining optionsSQL2)鍵入show parameter instance_name來查看實(shí)例名稱SQL show parameter instance_nameNAME TYPE VALUE instance_name string orcl3.試著利用SQL Plus來創(chuàng)建一個(gè)新表test (id number, name varchar2(20))。1 row updated.SQL select * from lob_dest。Import: Release Production on 星期三 7月 13 00:10:09 2011Copyright (c) 1982, 2004, Oracle. All rights reserved.Connected to: Oracle Database 10g Enterprise Edition Release ProductionWith the Partitioning,