GO ON 繼續(xù)進(jìn)階?。?br /> ??SQL*PLUS基礎(chǔ) ??在上一貼中,我們把握了些基本的Oracle操作,如創(chuàng)建、授權(quán)用戶,創(chuàng)建數(shù)據(jù)庫(kù)等。在OEM(Oracle EnterPRise Manager)可視化的窗口環(huán)境中,雖然我們也可以很方便地做這些事,但是事實(shí)上,用SQL語(yǔ)言書寫在開發(fā)上更有效率!!oracle提供的SQL*Plus就是個(gè)不錯(cuò)的工具,假如大家喜歡窗口的開發(fā)環(huán)境,用SQLPlus Worksheet也行!下面說點(diǎn)基本的西西!
??1.數(shù)據(jù)查詢語(yǔ)言DQL的基本結(jié)構(gòu)是由select子句,from子句,where子句組成的查詢塊: ??select <字段名表 designtimesp=4043> from <表或視圖名 designtimesp=4044> where <查詢條件 designtimesp=4045>
??接下來(lái),我們?cè)赟QL*Plus中實(shí)戰(zhàn)一下,為我們下面將要做的打好基礎(chǔ)。 ??用system登陸到SQL*Plus后,我們做如下操作(這次沒有截圖,有具體的說明) ??SQL>create user maxuan identified by max; #創(chuàng)建口令為max的用戶maxuan ??SQL>grant connect,resource to maxuan; #為用戶maxuan授權(quán) ??SQL>conn maxuan/max; #以用戶maxuan進(jìn)行連接 ??L>create table test(a number); #建立一個(gè)名為test的表,只有字段名為A的一列,數(shù)據(jù)類型為數(shù)字 ??SQL>insert into test values(1); #插入一條記錄 ??SQL>select * from test; #查詢記錄,此時(shí)A列的第一行為1 ??SQL>update test set a=2; #更改記錄,此時(shí)A列的第一行已改為2 ??SQL>commit; #提交 ??SQL>delete from test; #刪除test表中所有的記錄,此時(shí)test表中沒有記錄 ??SQL>roll; #回滾到提交前,此時(shí)再查詢test表,A列第一行值又回復(fù)到2
rem ///BY MAXUAN 開始/// create table item( type_id integer not null, type varchar2(30), constraint item_pk primary key(type_id) );
create table product( product_id integer not null, title varchar2(30) not null, type_id integer not null, info varchar2(80), price number(16,2) not null, constraint product_pk primary key (product_id), constraint product_fk foreign key(type_id) references item(type_id) );
create table orders( order_id integer not null, name varchar2(20) not null, address varchar2(100), tel number(16), email varchar2(30) not null, btime date, product_id integer not null, uword varchar2(100), constraint orders_pk primary key(order_id), constraint orders_fk foreign key(product_id) references product(product_id) );
create table admin( admin_id integer not null, adminname varchar2(20) not null, password varchar2(20) not null, constraint admin_pk primary key(admin_id) );
create sequence type_id increment by 1 start with 1; create sequence product_id increment by 1 start with 1; create sequence order_id increment by 1 start with 1; create sequence admin_id increment by 1 start with 1;