锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久亚洲中文字幕精品一区,亚洲国产成人久久一区二区三区,亚洲va久久久噜噜噜久久天堂http://m.tkk7.com/Good-Game/category/23017.htmlzh-cnThu, 29 May 2008 07:03:57 GMTThu, 29 May 2008 07:03:57 GMT60- 鏁版嵁搴撹〃鍦板潃鏁版嵁錛堜腑鍥藉湴鍖猴級http://m.tkk7.com/Good-Game/archive/2008/05/29/203747.htmlG_GG_GThu, 29 May 2008 02:51:00 GMThttp://m.tkk7.com/Good-Game/archive/2008/05/29/203747.htmlhttp://m.tkk7.com/Good-Game/comments/203747.htmlhttp://m.tkk7.com/Good-Game/archive/2008/05/29/203747.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/203747.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/203747.html聽CREATE聽TABLE聽`location`聽(聽聽`id`聽bigint(20)聽NOT聽NULL聽auto_increment,聽聽`name`聽varchar(50... 闃呰鍏ㄦ枃

]]> - mysql 鏉冮檺鎺у埗絎旇http://m.tkk7.com/Good-Game/archive/2008/04/29/197206.htmlG_GG_GTue, 29 Apr 2008 05:52:00 GMThttp://m.tkk7.com/Good-Game/archive/2008/04/29/197206.htmlhttp://m.tkk7.com/Good-Game/comments/197206.htmlhttp://m.tkk7.com/Good-Game/archive/2008/04/29/197206.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/197206.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/197206.html
MySQL
瀛樺彇鎺у埗鍖呭惈2涓樁孌碉細
- 闃舵1錛氭湇鍔″櫒媯鏌ユ槸鍚﹀厑璁鎬綘榪炴帴銆?/li>
- 闃舵2錛氬亣瀹氫綘鑳借繛鎺ワ紝鏈嶅姟鍣ㄦ鏌ヤ綘鍙戝嚭鐨勬瘡涓姹傘傜湅浣犳槸鍚︽湁瓚沖鐨勬潈闄愬疄鏂藉畠銆備緥濡傦紝濡傛灉浣犱粠鏁版嵁搴撹〃涓夋嫨(select)琛屾垨浠庢暟鎹簱鍒犻櫎琛紝鏈嶅姟鍣ㄧ‘瀹氫綘瀵硅〃鏈?span>SELECT鏉冮檺鎴栧鏁版嵁搴撴湁DROP鏉冮檺銆?/li>
鍙傝?錛?
5.8. MySQL鐢ㄦ埛璐︽埛綆$悊
1.鏉冮檺鏌ョ湅
mysql>聽show聽grants聽for聽'root'@'localhost'聽;
+---------------------------------------------------------------------+
|聽Grants聽for聽root@localhost聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽|
+---------------------------------------------------------------------+
|聽GRANT聽ALL聽PRIVILEGES聽ON聽*.*聽TO聽'root'@'localhost'聽WITH聽GRANT聽OPTION聽|
+---------------------------------------------------------------------+
1聽row聽in聽set聽(0.06聽sec)
2.鏉冮檺璁劇疆
5.8.2. 鍚慚ySQL澧炲姞鏂扮敤鎴瘋處鎴?/a>
mysql>聽GRANT聽ALL聽PRIVILEGES聽ON聽*.*聽TO聽'monty'@'localhost'
聽聽聽聽->聽聽聽聽聽IDENTIFIED聽BY聽'some_pass'聽WITH聽GRANT聽OPTION;
mysql>聽GRANT聽ALL聽PRIVILEGES聽ON聽*.*聽TO聽'monty'@'%'
聽聽聽聽->聽聽聽聽聽IDENTIFIED聽BY聽'some_pass'聽WITH聽GRANT聽OPTION;
聽聽
鍏朵腑涓や釜璐︽埛鏈夌浉鍚岀殑鐢ㄦ埛鍚?span>monty鍜屽瘑鐮?span>some_pass銆備袱涓處鎴峰潎涓鴻秴綰х敤鎴瘋處鎴鳳紝鍏鋒湁瀹屽叏鐨勬潈闄愬彲浠ュ仛浠諱綍浜嬫儏銆備竴涓處鎴?span>
('monty'@'localhost')鍙敤浜庝粠鏈満榪炴帴鏃躲傚彟涓涓處鎴?span>('monty'@'%')鍙敤浜庝粠鍏跺畠涓繪満榪炴帴銆?/font>
mysql>聽GRANT聽RELOAD,PROCESS聽ON聽*.*聽TO聽'admin'@'localhost';
璇ヨ處鎴峰彧鐢ㄤ簬浠庢湰鏈鴻繛鎺ャ傛巿浜堜簡RELOAD鍜?span>PROCESS綆$悊鏉冮檺銆傝繖浜涙潈闄愬厑璁?span>admin鐢ㄦ埛鎵цmysqladmin
reload銆?strong>mysqladmin
refresh鍜?strong>mysqladmin
flush-xxx鍛戒護錛屼互鍙?strong>mysqladmin
processlist銆傛湭鎺堜簣璁塊棶鏁版嵁搴撶殑鏉冮檺銆備綘鍙互閫氳繃GRANT璇彞娣誨姞姝ょ被鏉冮檺銆?/font>
mysql>聽GRANT聽USAGE聽ON聽*.*聽TO聽'dummy'@'localhost';
聽聽聽
涓涓處鎴鋒湁鐢ㄦ埛鍚?span>dummy錛屾病鏈夊瘑鐮併傝璐︽埛鍙敤浜庝粠鏈満榪炴帴銆傛湭鎺堜簣鏉冮檺銆傞氳繃GRANT璇彞涓殑USAGE鏉冮檺錛屼綘鍙互鍒涘緩璐︽埛鑰屼笉鎺堜簣浠諱綍鏉冮檺銆傚畠鍙互灝嗘墍鏈夊叏灞鏉冮檺璁句負'N'銆傚亣瀹氫綘灝嗗湪浠ュ悗灝嗗叿浣撴潈闄愭巿浜堣璐︽埛銆?/font>
涓嬮潰鐨勪緥瀛愬垱寤?span>3涓處鎴鳳紝鍏佽瀹冧滑璁塊棶涓撶敤鏁版嵁搴撱傛瘡涓處鎴風殑鐢ㄦ埛鍚嶄負custom錛屽瘑鐮佷負obscure銆?br />
mysql>聽GRANT聽SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
聽聽聽聽->聽聽聽聽聽ON聽bankaccount.*
聽聽聽聽->聽聽聽聽聽TO聽'custom'@'localhost'
聽聽聽聽->聽聽聽聽聽IDENTIFIED聽BY聽'obscure';
mysql>聽GRANT聽SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
聽聽聽聽->聽聽聽聽聽ON聽expenses.*
聽聽聽聽->聽聽聽聽聽TO聽'custom'@'whitehouse.gov'
聽聽聽聽->聽聽聽聽聽IDENTIFIED聽BY聽'obscure';
mysql>聽GRANT聽SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
聽聽聽聽->聽聽聽聽聽ON聽customer.*
聽聽聽聽->聽聽聽聽聽TO聽'custom'@'server.domain'
聽聽聽聽->聽聽聽聽聽IDENTIFIED聽BY聽'obscure';
榪?涓處鎴峰彲浠ョ敤浜庯細
路聽聽聽聽聽聽聽聽聽絎?涓處鎴峰彲浠ヨ闂産ankaccount鏁版嵁搴擄紝浣嗗彧鑳戒粠鏈満璁塊棶銆?br />
路聽聽聽聽聽聽聽聽聽絎?涓處鎴峰彲浠ヨ闂甧xpenses鏁版嵁搴擄紝浣嗗彧鑳戒粠涓繪満whitehouse.gov璁塊棶銆?br />
路聽聽聽聽聽聽聽聽聽絎?涓處鎴峰彲浠ヨ闂甤ustomer鏁版嵁搴擄紝浣嗗彧鑳戒粠涓繪満server.domain璁塊棶銆?br />
瑕佹兂涓嶇敤GRANT璁劇疆custom璐︽埛錛屼嬌鐢↖NSERT璇彞鐩存帴淇敼聽鎺堟潈琛細
5.8.3.聽浠嶮ySQL鍒犻櫎鐢ㄦ埛璐︽埛
DROP USER user;

]]>- mysql 娓告爣浣跨敤http://m.tkk7.com/Good-Game/archive/2008/04/27/196486.htmlG_GG_GSun, 27 Apr 2008 09:05:00 GMThttp://m.tkk7.com/Good-Game/archive/2008/04/27/196486.htmlhttp://m.tkk7.com/Good-Game/comments/196486.htmlhttp://m.tkk7.com/Good-Game/archive/2008/04/27/196486.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/196486.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/196486.html嫻嬭瘯琛?level ;
create table test.level (name varchar(20));
鍐?insert 浜涙暟鎹?;
聽/*鍒濆鍖?/span>*/聽
聽drop聽procedure聽if聽exists聽聽useCursor聽//聽聽聽聽
聽
聽/*寤虹珛聽瀛樺偍榪囩▼聽create聽*/聽
聽CREATE聽PROCEDURE聽useCursor()
聽聽聽聽BEGIN
聽聽聽聽/*灞閮ㄥ彉閲忕殑瀹氫箟聽declare*/聽
聽聽聽聽聽聽聽聽聽declare聽tmpName聽varchar(20)聽default聽''聽;
聽聽聽聽聽聽聽聽聽declare聽allName聽varchar(255)聽default聽''聽;
聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽declare聽cur1聽CURSOR聽FOR聽SELECT聽name聽FROM聽test.level聽;
聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽/*聽聽聽聽mysql聽涓嶇煡閬撲負浠涔堢敤寮傚父鍔犲叆鍒ゆ柇聽錛?br />聽聽聽聽聽聽聽聽聽聽*聽聽聽聽姝よ鍙傝冨畼鏂規枃妗?20.2.11.
鍏夋爣 鍏夋爣聽
聽聽聽聽聽聽聽聽聽聽*聽聽聽聽聽聽聽聽榪欐妸聽娓告爣聽寮傚父鍚幝犳崟鎹壜?br />聽聽聽聽聽聽聽聽聽聽*聽聽聽聽聽聽聽聽騫惰緗犲驚鐜嬌鐢犲彉閲徛爐mpname聽涓郝爊ull聽璺沖嚭寰幆銆?br />聽聽聽聽聽聽聽聽聽聽*/
聽聽聽聽聽聽聽聽聽declare聽CONTINUE聽HANDLER聽FOR聽SQLSTATE聽'02000'聽SET聽tmpname聽=聽null;
聽聽聽聽
聽聽聽聽
聽聽聽聽/*寮娓告爣*/聽
聽聽聽聽聽OPEN聽cur1;
聽聽聽聽聽聽聽聽聽/*娓告爣鍚戜笅璧頒竴姝?/span>*/聽
聽聽聽聽聽聽聽聽聽FETCH聽cur1聽INTO聽tmpName;
聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽/*聽寰幆浣撀犺繖寰堟槑鏄韭犳妸娓告爣鏌ヨ鍑虹殑聽name聽閮藉姞璧峰茍鐢?聽鍙烽殧寮聽*/
聽聽聽聽聽聽WHILE聽(聽tmpname聽is聽not聽null)聽DO
聽聽聽聽聽聽聽聽聽聽set聽tmpName聽=聽CONCAT(tmpName聽,";")聽;
聽聽聽聽聽聽聽 聽 set聽allName聽=聽CONCAT(allName聽,tmpName)聽;
聽聽聽聽聽聽聽聽/*娓告爣鍚戜笅璧頒竴姝?/span>*/聽
聽聽聽聽聽聽聽聽FETCH聽cur1聽INTO聽tmpName;
聽聽聽聽聽聽END聽WHILE;
聽聽
聽聽聽聽CLOSE聽cur1;
聽聽聽聽
聽聽聽聽select聽allName聽;
END;//
call聽useCursor()//
聽
榪愯緇撴灉錛?br />mysql>聽call聽useCursor()//
+--------------------------------------+
|聽allName聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽|
+--------------------------------------+
|聽f1;c3;c6;c5;c2;c4;c1;f1;f3;f4;f2;f5;聽|
+--------------------------------------+
1聽row聽in聽set聽(0.00聽sec)

]]> - mysql 鏁版嵁搴撳涔狅紙瑙﹀彂鍣級http://m.tkk7.com/Good-Game/archive/2008/01/24/177559.htmlG_GG_GThu, 24 Jan 2008 10:26:00 GMThttp://m.tkk7.com/Good-Game/archive/2008/01/24/177559.htmlhttp://m.tkk7.com/Good-Game/comments/177559.htmlhttp://m.tkk7.com/Good-Game/archive/2008/01/24/177559.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/177559.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/177559.html聽寮曠敤錛?a >21. 瑙﹀彂紼嬪簭
delimiter聽//
create聽trigger聽a_bi
before聽insert聽on聽a
for聽each聽row聽Begin
聽聽聽聽if聽new.s2=0聽then
聽聽聽聽聽聽if(new.s3=1)聽then
聽聽聽聽聽聽聽聽insert聽into聽b(s2)聽values(new.s1);
聽聽聽聽聽聽elseif(new.s3=2)then
聽聽聽聽聽聽聽聽insert聽into聽c(s2)聽values(new.s1);
聽聽聽聽聽聽end聽if;
聽聽聽聽end聽if;
聽聽聽聽end;//
delimiter聽;

]]>- mysql 鏁版嵁搴撳涔狅紙瀛樺偍榪囩▼錛?/title>http://m.tkk7.com/Good-Game/archive/2008/01/22/177105.htmlG_GG_GTue, 22 Jan 2008 09:58:00 GMThttp://m.tkk7.com/Good-Game/archive/2008/01/22/177105.htmlhttp://m.tkk7.com/Good-Game/comments/177105.htmlhttp://m.tkk7.com/Good-Game/archive/2008/01/22/177105.html#Feedback0http://m.tkk7.com/Good-Game/comments/commentRss/177105.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/177105.html寮曠敤錛?span class="section">20.2.1. CREATE
PROCEDURE鍜孋REATE FUNCTION錛坢ysql鍦ㄧ嚎鏂囨。錛?/a>
--test.sql
DELIMITER聽$$
drop聽procedure聽if聽exists聽test.sproc聽$$
create聽procedure聽sproc(out聽param1聽int)
begin
聽聽聽聽select聽count(*)聽into聽param1聽from聽account;
end聽$$
DELIMITER聽;
鍛戒護 cmd-> mysql -u root test<c:\test.sql
浣跨敤錛?br />mysql>聽call聽sproc(@a);
Query聽OK,聽0聽rows聽affected聽(0.00聽sec)
mysql>聽select聽@a聽;
+------+
|聽@a聽聽聽|
+------+
|聽1聽聽聽聽|
+------+
1聽row聽in聽set聽(0.00聽sec)

]]> - ORACLE絎旇 sql璇彞 (杞?http://m.tkk7.com/Good-Game/archive/2007/04/12/110243.htmlG_GG_GThu, 12 Apr 2007 10:09:00 GMThttp://m.tkk7.com/Good-Game/archive/2007/04/12/110243.htmlhttp://m.tkk7.com/Good-Game/comments/110243.htmlhttp://m.tkk7.com/Good-Game/archive/2007/04/12/110243.html#Feedback1http://m.tkk7.com/Good-Game/comments/commentRss/110243.htmlhttp://m.tkk7.com/Good-Game/services/trackbacks/110243.html銆銆--==================================== 涓.sql璇彞
銆銆--================================================
銆銆1.澧炲姞涓婚敭
銆銆 alter table TABLE_NAME add constraint KEY_NAME primary key (TABLE_COLUMN);
銆銆 鎸囧畾琛ㄧ┖闂?br />銆銆 alter table TABLE_NAME add constraint KEY_NAME primary key (TABLE_COLUMN) using index tablespace TABLE_SPACE_NAME;
銆銆2.澧炲姞澶栭敭
銆銆 alter table TABLE_NAME add constraint FK_NAME foreign key (TABLE_COLUMN) references KEY_TABLE_NAME;
銆銆3.浣夸富閿垨澶栭敭澶辨晥銆佺敓鏁?br />銆銆 alter table TABLE_NAME disable(enable) constraint KEY_NAME;
銆銆4銆佹煡鐪嬪悇縐嶇害鏉?br />銆銆 select constraint_name,table_name,constraint_type,status from user_constraints;
select constraint_name, constraint_type,search_condition,
r_constraint_name from user_constraints where table_name =
upper('&table_name')
銆銆 select c.constraint_name,c.constraint_type,cc.column_name
銆銆 from user_constraints c,user_cons_columns cc
銆銆 where c.owner = upper('&table_owner') and c.table_name = upper('&table_name')
銆銆 and c.owner = cc.owner and c.constraint_name = cc.constraint_name
銆銆 order by cc.position;
銆銆5銆佸垹闄や富閿垨澶栭敭
銆銆 alter table TABLE_NAME drop constraint KEY_NAME;
銆銆6銆佸緩澶栭敭
銆銆 鍗曞瓧孌墊椂錛歝reate table 琛ㄥ悕 (col1 char(8),
銆銆 cno char(4) REFERENCE course);
銆銆 澶氫釜瀛楁鏃?鍦ㄦ渶鍚庡姞涓?Foreign Key (瀛楁鍚? REFERENCE 琛ㄥ悕(瀛楁)
銆銆 榪炲甫鍒犻櫎閫夐」 (on delete cascade
銆銆 褰撴寚瀹氭椂錛屽鏋滅埗琛ㄤ腑鐨勮褰曡鍒犻櫎錛屽垯渚濊禆浜庣埗琛ㄧ殑璁板綍涔熻鍒犻櫎
銆銆 REFERENCE 琛ㄥ悕錛堬級 on delete cascade;
銆銆7銆佸垹闄ゅ甫綰︽潫鐨勮〃
銆銆 Drop table 琛ㄥ悕 cascade constraints;
銆銆8錛氱儲寮曠鐞?br />銆銆<1>.creating function-based indexes
銆銆sql> create index summit.item_quantity on summit.item(quantity-quantity_shipped);
銆銆<2>.create a B-tree index
銆銆sql> create [unique] index index_name on table_name(column,.. asc/desc) tablespace
銆銆sql> tablespace_name [pctfree integer] [initrans integer] [maxtrans integer]
銆銆sql> [logging | nologging] [nosort] storage(initial 200k next 200k pctincrease 0
銆銆sql> maxextents 50);
銆銆<3>.pctfree(index)=(maximum number of rows-initial number of rows)*100/maximum number of rows
銆銆<4>.creating reverse key indexes
銆銆sql> create unique index xay_id on xay(a) reverse pctfree 30 storage(initial 200k
銆銆sql> next 200k pctincrease 0 maxextents 50) tablespace indx;
銆銆<5>.create bitmap index
銆銆sql> create bitmap index xay_id on xay(a) pctfree 30 storage( initial 200k next 200k
銆銆sql> pctincrease 0 maxextents 50) tablespace indx;
銆銆<6>.change storage parameter of index
銆銆sql> alter index xay_id storage (next 400k maxextents 100);
銆銆7.allocating index space
銆銆sql> alter index xay_id allocate extent(size 200k datafile 'c:/oracle/index.dbf');
銆銆<8>.alter index xay_id deallocate unused;
銆銆<9>銆佹煡鐪嬬儲寮?br />銆銆 SQL>select index_name,index_type,table_name from user_indexes order by table_name;
銆銆<10>銆佹煡鐪嬬儲寮曡绱㈠紩鐨勫瓧孌?br />銆銆 SQL>select * from user_ind_columns where index_name=upper('&index_name');
銆銆11銆佸垱寤哄簭鍒?br />銆銆 select * from user_sequences;
銆銆 create sequence SEQ_NAME start with 1000
銆銆 maxvalue 1000 increment by 1;
銆銆 alter sequence SEQ_NAME minvalue 50 maxvalue 100;
銆銆12銆佸垹闄ら噸澶嶈
銆銆 update a set aa=null where aa is not null;
銆銆
銆銆 delete from a where rowid!=
銆銆 (select max(rowid) from a b where a.aa=b.aa);
銆銆13銆佸垹闄ゅ悓鍏朵粬琛ㄧ浉鍚岀殑琛?br />銆銆 delete from a where exits
銆銆 (select 'X' from b where b.no=a.no);
銆銆 鎴?br />銆銆 delete from a where no in (select no from b);
銆銆14銆佹煡璇粠澶氬皯琛屽埌澶氬皯琛岀殑璁板綍(鍙互鐢ㄥ湪web寮鍙戜腑鐨勫垎欏墊樉紺?
銆銆 select * from ( select rownum row_id,b.* from (select a.* from sys_oper a) b )
銆銆 where row_id between 15 and 20
銆銆15銆佸鍏叡鎺堜簣璁塊棶鏉?br />銆銆 grant select on 琛ㄥ悕 to public;
銆銆 create public synonym 鍚屼箟璇嶅悕 for 琛ㄥ悕;
銆銆16銆佸~鍔犳敞閲?br />銆銆 comment on table 琛ㄥ悕 is '娉ㄩ噴';
銆銆 comment on column 琛ㄥ悕.鍒楀悕 is '娉ㄩ噴';
銆銆17銆佸垎甯冨紡鏁版嵁搴?鍒涘緩鏁版嵁搴撻摼璺?br />銆銆 create [public] database link LINKNAME
銆銆 [connect to USERNAME identified by PASSWORD]
銆銆 [using 'CONNECT_STRING']
銆銆 鍙互鍦ㄦ湇鍔″櫒绔紝涔熷彲浠ュ湪瀹㈡埛绔緩绔嬶紝浣嗗繀欏繪敞鎰忥紝涓ゅ彴鏈嶅姟鍣ㄤ箣闂?br />銆銆 鏁版嵁搴撳繀欏誨彲浠ヤ簰璁匡紝蹇呴』鍚勬湁鍚勮嚜鐨勫埆鍚嶆暟鎹簱
銆銆18銆佹煡鐪嬫暟鎹簱閾捐礬
銆銆 select * from all_db_links;
銆銆 select * from user_db_links;
銆銆 鏌ヨ select * from TABLENAME@DBLNKNAME;
銆銆 鍒涘緩榪滅▼鏁版嵁搴撳悓涔夎瘝
銆銆 create synonym for TABLENAME@DBLNKNAME;
銆銆 鎿嶇旱榪滅▼鏁版嵁搴撹褰?br />銆銆 insert into TABLENAME@DBLNKNAME (a,b) values (va,vb);
銆銆 update TABLENAME@DBLNKNAME set a='this';
銆銆 delete from TABLENAME@DBLNKNAME;
銆銆 鎬庢牱鎵ц榪滅▼鐨勫唴宓岃繃紼?br />銆銆 begin
銆銆 otherdbpro@to_html(鍙傛暟);
銆銆 end;
銆銆19銆佹暟鎹簱閾捐礬鐢ㄦ埛瀵嗙爜鏈夌壒孌婂瓧絎︾殑鏃跺欙紝鍙互鐢ㄥ弻寮曞彿鎶婂瘑鐮佸紩璧鋒潵
銆銆create public database link dblink1 connect to db1 identified by "123*456" using 'db11'
銆銆20.oracle8涓墿鍏呬簡group by rollup鍜宑ube鐨勬搷浣溿傛湁鏃跺欑渷浜嗕綘濂藉鍔熷か鐨勩?br />銆銆 <1>涓嬮潰鐨勮鍙ュ彲浠ヨ繘琛屾昏
銆銆 select region_code,count(*) from aicbs.acc_woff_notify
銆銆 group by rollup(region_code);
銆銆 <2> 瀵圭1涓瓧孌靛皬璁★紝鏈鍚庡悎璁?br />銆銆 select region_code,write_status,count(*) from aicbs.acc_woff_notify
銆銆 group by rollup(region_code,write_status);
銆銆 ----------------------
銆銆 570 0 3
銆銆 570 1 2
銆銆 570 5 --姝ゅ灝忚浜?70鐨勮褰?br />銆銆 571 0 10
銆銆 571 1 2
銆銆 571 12 --姝ゅ灝忚浜?71鐨勮褰?br />銆銆 .....
銆銆 100 --姝ゅ鏈夋昏
銆銆 <3> 澶嶅悎rollup琛ㄨ揪寮?鍙仛鎬昏
銆銆 select region_code,write_status,count(*) from aicbs.acc_woff_notify
銆銆 group by rollup(region_code,write_status);
銆銆
銆銆 <4> 瀵圭1涓瓧孌靛皬璁★紝鍐嶅絎?涓瓧孌靛皬璁★紝鏈鍚庡悎璁?br />銆銆 select region_code,write_status,count(*) from aicbs.acc_woff_notify
銆銆 group by cube(region_code,write_status);
銆銆 ----------------------
銆銆 100 --姝ゅ鏈夋昏
銆銆 0 60 --瀵箇rite_status錛?鐨勫皬璁?br />銆銆 1 39 --瀵箇rite_status錛?鐨勫皬璁?br />銆銆 3 1 --瀵箇rite_status錛?鐨勫皬璁?br />銆銆 570 5 --姝ゅ灝忚浜?70鐨勮褰?br />銆銆 570 0 3
銆銆 570 1 2
銆銆 571 12 --姝ゅ灝忚浜?71鐨勮褰?br />銆銆 571 0 10
銆銆 571 1 2
銆銆 ....
銆銆 <3> 澶嶅悎cube琛ㄨ揪寮?鍙仛鎬昏
銆銆 select region_code,write_status,count(*) from aicbs.acc_woff_notify
銆銆 group by cube(region_code,write_status);
銆銆
銆銆
銆銆 <4>涓嬮潰鐨勮鍙ュ彲浠ユ寜鐓ollup涓嶅悓鐨勫瓧孌佃繘琛屽皬璁?br />銆銆 select region_code,write_status,count(*) from aicbs.acc_woff_notify
銆銆 group by region_code,rollup(write_status);
銆銆21.鏌ヨview鐨勫垱寤鴻鍙?br />銆銆 sql>set long 1000
銆銆 sql>select * from user_views where view_name='MY_VIEW_NAME';
銆銆 or
銆銆 sql>select * from all_views where view_name='MY_VIEW_NAME';
銆銆22銆佸幓闄ゆ暟鎹簱涓壒孌婂瓧絎?br />銆銆 <1>.瀛楃涓插瓧孌典腑鍚湁"'",濡傛灉鐢ㄦ潵緇勫悎sql璇彞錛屼細閫犳垚璇彞涓嶅噯紜?br />銆銆 姣斿錛歳eplace(f1,'''','')
銆銆 <2>.瀛楃涓插瓧孌典腑鍚湁"\t \n",濡傛灉鐢ㄦ潵鍦╟鎴栬卌錛嬶紜紼嬪簭涓緭鍑哄埌鏂囦歡錛屾牸寮忔棤娉曚繚璇併?br />銆銆 姣斿錛歳eplace(f2,'\t','')
銆銆 <3>.娓呴櫎鎹㈣鍜屽洖杞?br />銆銆 姣斿: replace(f2,chr(13)||chr(10),'')
銆銆23銆佸浣曞湪瀛楃涓查噷鍔犲洖杞︽垨鑰卼ab閿?
銆銆 鍦╯qlplus涓墽琛?br />銆銆 sql>select 'UserId=1233111'||chr(10)||'AccId=13431'||chr(9)||'AccId2=11111' from dual;
銆銆24銆佹爲褰㈡煡璇?br />銆銆create table zj(
銆銆bm number(8),
銆銆bmmc varchar2(20),
銆銆sjbm number(8)
銆銆)
銆銆insert into zj values(1,'aaa',0)
銆銆insert into zj values(11,'aaa1',1)
銆銆insert into zj values(12,'aaa2',1)
銆銆insert into zj values(111,'aaa11',11)
銆銆insert into zj values(112,'aaa12',11)
銆銆insert into zj values(113,'aaa13',11)
銆銆insert into zj values(121,'aaa21',12)
銆銆insert into zj values(122,'aaa22',12)
銆銆insert into zj values(123,'aaa23',12)
銆銆--
銆銆select bm,bmmc,sjbm,level
銆銆from zj
銆銆start with sjbm=0
銆銆connect by prior bm = sjbm
銆銆鎴栬?br />銆銆select bm,bmmc,sjbm,level
銆銆from zj
銆銆start with sjbm=0
銆銆connect by sjbm = prior bm
銆銆25銆佸揩鐓?br />銆銆 create snapshot SNAPSHOT_NAME
銆銆 [storage (storage parameter)]
銆銆 銆銆 [refresh [fast\complete\force]
銆銆 [start with START_DATE next NEXT_DATE]
銆銆 as QUERY;
銆銆
銆銆 create snapshot snapshot_to_study as select * from TABLE_NAME@to_study;
銆銆 鍒涘緩瑙掕壊
銆銆 create role aa identified by aaa;
銆銆 鎺堟潈 grant create snapshot,alter snapshot to aaa;
銆銆 grant aaa to emp;
銆銆 create snapshot SNAPSHOT_TO_HTML refresh complete start with sysdate next
銆銆 sysdate+5/(24*60*60) as select * from a@to_html;
銆銆 鍒犻櫎 drop snapshot snap_to_html
銆銆 鎵嬪伐鍒鋒柊蹇収,(璋冪敤DBMS_SNAPSHOT鍖呬腑鐨剅efresh榪囩▼)DBMS_SNAPSHOT.refresh(snapshot_name,refresh_type);
銆銆 begin
銆銆 DBMS_SNAPSHOT.REFRESH('snap_to_html','c');
銆銆 end;
銆銆 瀵規墍鏈夊揩鐓ц繘琛屽埛鏂?br />銆銆 begin
銆銆 DBMS_SNAPSHOT.REFRESH_ALL;
銆銆 end;
銆銆 鎬庢牱鎵ц榪滅▼鐨勫唴宓岃繃紼?br />銆銆 begin
銆銆 otherdbpro@to_html(鍙傛暟);
銆銆 end;
銆銆26銆佺敤鎴風鐞?br />銆銆 create a user: database authentication
銆銆 sql> create user juncky identified by oracle default tablespace users
銆銆 sql> temporary tablespace temp quota 10m on data password expire
銆銆 sql> [account lock|unlock] [profile profilename|default];
銆銆 <1>.鏌ョ湅褰撳墠鐢ㄦ埛鐨勭己鐪佽〃絀洪棿
銆銆 SQL>select username,default_tablespace from user_users;
銆銆 <2>鐢熸垚鐢ㄦ埛鏃舵寚瀹氱己鐪佽〃絀洪棿
銆銆 create user 鐢ㄦ埛鍚?identified by 鍙d護 default tablespace 琛ㄧ┖闂村悕;
銆銆
銆銆 <3>閲嶆柊鎸囧畾鐢ㄦ埛鐨勭己鐪佽〃絀洪棿
銆銆 alter user 鐢ㄦ埛鍚?default tablespace 琛ㄧ┖闂村悕
銆銆 <4>鏌ョ湅褰撳墠鐢ㄦ埛鐨勮鑹?br />銆銆 SQL>select * from user_role_privs;
銆銆 <5>鏌ョ湅褰撳墠鐢ㄦ埛鐨勭郴緇熸潈闄愬拰琛ㄧ駭鏉冮檺
銆銆 SQL>select * from user_sys_privs;
銆銆 SQL>select * from user_tab_privs;
銆銆 <6>鏌ョ湅鐢ㄦ埛涓嬫墍鏈夌殑琛?br />銆銆 SQL>select * from user_tables;
銆銆 <7> alter user璇彞鐨剄uota瀛愬彞闄愬埗鐢ㄦ埛鐨勭鐩樼┖闂?br />銆銆 濡?alter user jf quota 10M on system;
銆銆27銆佹煡鐪嬫斁鍦∣RACLE鐨勫唴瀛樺尯閲岀殑琛?
銆銆 SQL>select table_name,cache from user_tables where instr(cache,'Y')>0;
銆銆28銆佺害鏉熸潯浠?br />銆銆 create table employee
銆銆 (empno number(10) primary key,
銆銆 name varchar2(40) not null,
銆銆 deptno number(2) default 10,
銆銆 salary number(7,2) check salary<10000,
銆銆 birth_date date,
銆銆 soc_see_num char(9) unique,
銆銆 foreign key(deptno) references dept.deptno)
銆銆 tablespace users;
銆銆
銆銆 鍏抽敭瀛?primary key)蹇呴』鏄潪絀?琛ㄤ腑璁板綍鐨勫敮涓鎬?br />銆銆 not null 闈炵┖綰︽潫
銆銆 default 緙虹渷鍊肩害鏉?br />銆銆 check 媯鏌ョ害鏉?浣垮垪鐨勫肩鍚堜竴瀹氱殑鏍囧噯鑼冨洿
銆銆 unqiue 鍞竴鎬х害鏉?br />銆銆 foreign key 澶栭儴閿害鏉?br />銆銆29銆佹煡鐪嬪垱寤鴻鍥劇殑select璇彞
銆銆 SQL>set view_name,text_length from user_views;
銆銆 SQL>set long 2000; 璇存槑錛氬彲浠ユ牴鎹鍥劇殑text_length鍊艱瀹歴et long 鐨勫ぇ灝?br />銆銆 SQL>select text from user_views where view_name=upper('&view_name');
銆銆30銆佹煡鐪嬪悓涔夎瘝鐨勫悕縐?br />銆銆 SQL>select * from user_synonyms;
銆銆31銆佺敤Sql璇彞瀹炵幇鏌ユ壘涓鍒椾腑絎琋澶у?
銆銆select * from
銆銆(select t.*,dense_rank() over (order by sal) rank from employee)
銆銆where rank = N;
銆銆32 铏氭嫙鑷
銆銆 <1>. CURRVAL 鍜?nextval
銆銆 涓鴻〃鍒涘緩搴忓垪
銆銆 CREATE SEQUENCE EMPSEQ ... ;
銆銆 SELECT empseq.currval FROM DUAL ;
銆銆 鑷姩鎻掑叆搴忓垪鐨勬暟鍊?br />銆銆 INSERT INTO emp
銆銆 VALUES (empseq.nextval, 'LEWIS', 'CLERK',
銆銆 7902, SYSDATE, 1200, NULL, 20) ;
銆銆 <2>. ROWNUM
銆銆 鎸夎瀹氭帓搴忕殑琛岀殑搴忓彿
銆銆 SELECT * FROM emp WHERE ROWNUM < 10 ;
銆銆 <3>. ROWID
銆銆 榪斿洖琛岀殑鐗╃悊鍦板潃
銆銆 SELECT ROWID, ename FROM emp WHERE deptno = 20 ;
銆銆33銆佸CLOB瀛楁榪涜鍏ㄦ枃媯绱?br />銆銆SELECT * FROM A WHERE dbms_lob.instr(a.a,'K',1,1)>0;
銆銆34. 鐗規畩瀛楃鐨勬彃鍏ワ紝姣斿"&"
銆銆insert into a values (translate ('at{&}t','at{}','at'));
銆銆35.琛ㄧ鐞?br />銆銆 <1>.create a table
銆銆 sql> create table table_name (column datatype,column datatype]....)
銆銆 sql> tablespace tablespace_name [pctfree integer] [pctused integer]
銆銆 sql> [initrans integer] [maxtrans integer]
銆銆 sql> storage(initial 200k next 200k pctincrease 0 maxextents 50)
銆銆 sql> [logging|nologging] [cache|nocache]
銆銆 <2>.copy an existing table
銆銆 sql> create table table_name [logging|nologging] as subquery
銆銆
銆銆 <3> create table ... as 鏂瑰紡寤鴻〃鐨勬椂鍊欙紝鎸囧畾琛ㄥ弬鏁?br />銆銆 create table a
銆銆 storage(
銆銆 initial 1M /*絎竴嬈″垱寤烘椂鍒嗛厤絀洪棿*/
銆銆 next 1M /*絎竴嬈″垎閰嶇殑瀛樺偍絀洪棿鐢ㄥ畬鏃跺湪鍒嗛厤*/
銆銆 )
銆銆 as select * from b;
銆銆 <4>.鍒涘緩涓存椂琛?br />銆銆 sql> create global temporary table xay_temp as select * from xay;
銆銆 on commit preserve rows/on commit delete rows
銆銆 鍦∣racle涓紝鍙互鍒涘緩浠ヤ笅涓ょ涓存椂琛?
銆銆 a 浼氳瘽鐗規湁鐨勪復鏃惰〃:
銆銆 create global temporary table () on commit preserve rows;
銆銆 浼氳瘽鎸囧畾錛屽綋涓柇浼氳瘽鏃禣RACLE灝嗘埅鏂〃
銆銆 b 浜嬪姟鐗規湁鐨勪復鏃惰〃:
銆銆 create global temporary table () on commit delete rows;
銆銆 浜嬪姟鎸囧畾,姣忔鎻愪氦鍚嶰RACLE灝嗘埅鏂〃錛堝垹闄ゅ叏閮ㄨ錛?
銆銆 c 璇存槑
銆銆 涓存椂琛ㄥ彧鍦ㄥ綋鍓嶈繛鎺ュ唴鏈夋晥
銆銆涓存椂琛ㄤ笉寤虹珛绱㈠紩,鎵浠ュ鏋滄暟鎹噺姣旇緝澶ф垨榪涜澶氭鏌ヨ鏃?涓嶆帹鑽愪嬌鐢?
銆銆鏁版嵁澶勭悊姣旇緝澶嶆潅鐨勬椂鍊欐椂琛ㄥ揩,鍙嶄箣瑙嗗浘蹇偣
銆銆鍦ㄤ粎浠呮煡璇㈡暟鎹殑鏃跺欏緩璁敤娓告爣: open cursor for 'sql clause';
銆銆 <5>
銆銆 pctfree = (average row size - initial row size) *100 /average row size
銆銆 pctused = 100-pctfree- (average row size*100/available data space)
銆銆 <6>.change storage and block utilization parameter
銆銆 sql> alter table table_name pctfree=30 pctused=50 storage(next 500k
銆銆 sql> minextents 2 maxextents 100);
銆銆 <7>.manually allocating extents
銆銆 sql> alter table table_name allocate extent(size 500k datafile 'c:/oracle/data.dbf');
銆銆 <8>.move tablespace
銆銆 sql> alter table employee move tablespace users;
銆銆 <9>.deallocate of unused space
銆銆 sql> alter table table_name deallocate unused [keep integer]
銆銆 <10>.drop a column
銆銆 sql> alter table table_name drop column comments cascade constraints checkpoint 1000;
銆銆 alter table table_name drop columns continue;
銆銆 <11>.mark a column as unused
銆銆 sql> alter table table_name set unused column comments cascade constraints;
銆銆 alter table table_name drop unused columns checkpoint 1000;
銆銆 alter table orders drop columns continue checkpoint 1000
銆銆 data_dictionary : dba_unused_col_tabs
銆銆37. 涓枃鏄浣曟帓搴忕殑錛?
銆銆Oracle9i涔嬪墠錛屼腑鏂囨槸鎸夌収浜岃繘鍒剁紪鐮佽繘琛屾帓搴忕殑銆?
銆銆鍦╫racle9i涓柊澧炰簡鎸夌収鎷奸煶銆侀儴棣栥佺瑪鐢繪帓搴忓姛鑳姐傝緗甆LS_SORT鍊?
銆銆SCHINESE_RADICAL_M 鎸夌収閮ㄩ錛堢涓欏哄簭錛夈佺瑪鍒掞紙絎簩欏哄簭錛夋帓搴?
銆銆SCHINESE_STROKE_M 鎸夌収絎斿垝錛堢涓欏哄簭錛夈侀儴棣栵紙絎簩欏哄簭錛夋帓搴?
銆銆SCHINESE_PINYIN_M 鎸夌収鎷奸煶鎺掑簭
銆銆38. 鏁版嵁琛ㄤ腑鐨勫瓧孌墊渶澶ф暟:
銆銆琛ㄦ垨瑙嗗浘涓殑鏈澶у垪鏁頒負 1000
銆銆39. oracle涓殑瑁歌澶?
銆銆 瑁歌澶囧氨鏄粫榪囨枃浠剁郴緇熺洿鎺ヨ闂殑鍌ㄥ瓨絀洪棿
銆銆40. 鍦∣racle鏈嶅姟鍣ㄤ笂閫氳繃SQLPLUS鏌ョ湅鏈満IP鍦板潃 ?
銆銆select sys_context('userenv','ip_address') from dual;
銆銆濡傛灉鏄櫥闄嗘湰鏈烘暟鎹簱錛屽彧鑳借繑鍥?27.0.0.1
銆銆41. 鍦∣RACLE涓彇姣?
銆銆 9i涔嬪墠涓嶆敮鎸?9i寮濮嬫湁timestamp.
銆銆 9i鍙互鐢╯elect systimestamp from dual;
銆銆42. 灝哊縐掕漿鎹負鏃跺垎縐掓牸寮忥紵
銆銆 set serverout on
銆銆 declare
銆銆 N number := 1000000;
銆銆 ret varchar2(100);
銆銆 begin
銆銆 ret := trunc(n/3600) || '灝忔椂' || to_char(to_date(mod(n,3600),'sssss'),'fmmi"鍒?"ss"縐?') ;
銆銆 dbms_output.put_line(ret);
銆銆 end;
銆銆43銆佸湪鏌愪釜鐢ㄦ埛涓嬫壘鎵鏈夌殑绱㈠紩
銆銆 select user_indexes.table_name, user_indexes.index_name,uniqueness, column_name
銆銆 from user_ind_columns, user_indexes
銆銆 where user_ind_columns.index_name = user_indexes.index_name
銆銆 and user_ind_columns.table_name = user_indexes.table_name
銆銆 order by user_indexes.table_type, user_indexes.table_name,
銆銆 user_indexes.index_name, column_position;
銆銆44. not in鐨勬浛浠c?br />銆銆 涓鑸琻ot in鐨勬晥鐜囨瘮杈冧綆銆傜壒鍒槸鏁版嵁閲忓ぇ鐨勬椂鍊欙紝鍑犱箮涓嶈兘鎵ц銆?br />銆銆 鐢ㄤ笅闈㈠嚑縐嶆柟寮忓彲浠ユ浛鎹㈠啓娉?br />銆銆 姣斿瑕佹煡璇㈠湪fee_rev_info琛ㄤ腑宸茬粡閿鎴風殑鐢ㄦ埛錛堜笉鍦╟m_user涓殑錛?涓嶈繃涓嬮潰鐨勪緥瀛愪笉鏄緢濂斤紝鍥犱負bill_id鏄痗m_user鐨勫敮涓绱㈠紩錛?br />銆銆 select * from fee_rev_info where bill_id not in (select bill_id from cm_user)
銆銆 <1> 鐢╪ot exists
銆銆 select * from fee_rev_info a where not exists (select 'p' from cm_user b where b.bill_id = a.bill_id)
銆銆 <2> 鐢ㄥ榪炴帴(+)
銆銆 select a.* from fee_rev_info a,cm_user b
銆銆 where a.bill_id = b.bill_id (+)
銆銆 and b.bill_id is null
銆銆 <3> 鐢╤ash_aj
銆銆 select /*+HASH_AJ*/* from fee_rev_info where bill_id not in (select bill_id from cm_user)
銆銆45.鎬庝箞鏍鋒煡璇㈢壒孌婂瓧絎︼紝濡傞氶厤絎?涓巁
銆銆鍋囧鏁版嵁搴撲腑鏈夎〃 STATIONTYPE,STATION_571 STATION_572 ...
銆銆select * from tab where tname like 'STATION_%'
銆銆浼氭樉紺?STATIONTYPE,STATION_571 ... 鍙互鐢ㄤ笅闈㈢殑璇彞
銆銆select * from tab where tname like 'STATION\_%' escape'\'
銆銆46.濡傛灉瀛樺湪灝辨洿鏂幫紝涓嶅瓨鍦ㄥ氨鎻掑叆鍙互鐢ㄤ竴涓鍙ュ疄鐜板悧
銆銆9i宸茬粡鏀寔浜嗭紝鏄疢erge錛屼絾鏄彧鏀寔select瀛愭煡璇紝
銆銆濡傛灉鏄崟鏉℃暟鎹褰曪紝鍙互鍐欎綔select .... from dual鐨勫瓙鏌ヨ銆?br />銆銆璇硶涓猴細
銆銆MERGE INTO table
銆銆USING data_source
銆銆ON (condition)
銆銆WHEN MATCHED THEN update_clause
銆銆WHEN NOT MATCHED THEN insert_clause;
銆銆濡?br />銆銆MERGE INTO cm_user_credit
銆銆USING (select * from dual) ON (user_id =1302514690 )
銆銆when MATCHED then update set credit_value = 1000
when NOT MATCHED then insert
(user_id,acc_id,bill_id,plan_id,region_code,credit_value)
values(1302514690,1305032158,'13857141218',10070247,'571',1000);
銆銆47.鎬庝箞瀹炵幇涓鏉¤褰曟牴鎹潯浠跺琛ㄦ彃鍏?br />銆銆9i浠ヤ笂鍙互閫氳繃Insert all璇彞瀹屾垚錛屼粎浠呮槸涓涓鍙ワ紝濡傦細
銆銆INSERT ALL
銆銆WHEN (id=1) THEN
銆銆INTO table_1 (id, name)
銆銆values(id,name)
銆銆WHEN (id=2) THEN
銆銆INTO table_2 (id, name)
銆銆values(id,name)
銆銆ELSE
銆銆INTO table_other (id, name)
銆銆values(id, name)
銆銆SELECT id,name
銆銆FROM a;
銆銆濡傛灉娌℃湁鏉′歡鐨勮瘽錛屽垯瀹屾垚姣忎釜琛ㄧ殑鎻掑叆錛屽
銆銆INSERT ALL
銆銆INTO table_1 (id, name)
銆銆values(id,name)
銆銆INTO table_2 (id, name)
銆銆values(id,name)
銆銆INTO table_other (id, name)
銆銆values(id, name)
銆銆SELECT id,name
銆銆FROM a;
銆銆48.濡備綍瀹炵幇琛屽垪杞崲
銆銆<1>銆佸浐瀹氬垪鏁扮殑琛屽垪杞崲
銆銆濡?br />銆銆student subject grade
銆銆---------------------------
銆銆student1 璇枃 80
銆銆student1 鏁板 70
銆銆student1 鑻辮 60
銆銆student2 璇枃 90
銆銆student2 鏁板 80
銆銆student2 鑻辮 100
銆銆...
銆銆杞崲涓?
銆銆璇枃 鏁板 鑻辮
銆銆student1 80 70 60
銆銆student2 90 80 100
銆銆...
銆銆璇彞濡備笅錛?br />銆銆select student,sum(decode(subject,'璇枃', grade,null)) "璇枃",
銆銆sum(decode(subject,'鏁板', grade,null)) "鏁板",
銆銆sum(decode(subject,'鑻辮', grade,null)) "鑻辮"
銆銆from table
銆銆group by student
銆銆<2>銆佷笉瀹氬垪琛屽垪杞崲
銆銆濡?br />銆銆c1 c2
銆銆--------------
銆銆1 鎴?br />銆銆1 鏄?br />銆銆1 璋?br />銆銆2 鐭?br />銆銆2 閬?br />銆銆3 涓?br />銆銆...
銆銆杞崲涓?br />銆銆1 鎴戞槸璋?br />銆銆2 鐭ラ亾
銆銆3 涓?br />銆銆榪欎竴綾誨瀷鐨勮漿鎹㈠繀欏誨熷姪浜嶱L/SQL鏉ュ畬鎴愶紝榪欓噷緇欎竴涓緥瀛?br />銆銆CREATE OR REPLACE FUNCTION get_c2(tmp_c1 NUMBER)
銆銆RETURN VARCHAR2
銆銆IS
銆銆Col_c2 VARCHAR2(4000);
銆銆BEGIN
銆銆FOR cur IN (SELECT c2 FROM t WHERE c1=tmp_c1) LOOP
銆銆Col_c2 := Col_c2||cur.c2;
銆銆END LOOP;
銆銆Col_c2 := rtrim(Col_c2,1);
銆銆RETURN Col_c2;
銆銆END;
銆銆/
銆銆SQL> select distinct c1 ,get_c2(c1) cc2 from table;鍗沖彲
銆銆--渚嬪瓙錛?br />銆銆create table okcai_1
銆銆(
銆銆user_id varchar2(10),
銆銆user_number varchar2(10),
銆銆user_num number(8)
銆銆)
銆銆user_id user_number user_num
銆銆---------------------
銆銆1 123 2
銆銆1 456 5
銆銆1 789 6
銆銆2 11 2
銆銆2 22 3
銆銆2 33 4
銆銆2 44 5
銆銆2 55 6
銆銆2 66 7
銆銆2 77 8
銆銆3 1234 1
銆銆3 5678 2
銆銆鏂瑰紡涓錛?br />銆銆create or replace function get_col(
銆銆 p_userId number,
銆銆 p_col number
銆銆) return varchar
銆銆as
銆銆v_tmp varchar2(255);
銆銆begin
銆銆 select user_number||chr(9)||user_num into v_tmp
銆銆 from
銆銆 (select user_number,user_num,rownum row_id
銆銆 from okcai_1
銆銆 where user_id = p_userId) a
銆銆 where row_id = p_col;
銆銆 return ltrim(v_tmp);
銆銆 --return v_tmp;
銆銆end;
銆銆鐒跺悗
銆銆select distinct user_id,get_col(user_id,1),get_col(user_id,2),get_col(user_id,3) .... from okcai_1
銆銆鏂瑰紡浜岋細
銆銆create or replace function get_col(
銆銆 p_userId number,
銆銆 p_col number
銆銆) return varchar
銆銆as
銆銆v_tmp varchar2(255);
銆銆begin
銆銆 select user_number||chr(9)||user_num into v_tmp
銆銆 from
銆銆 (select user_number,user_num,rownum row_id
銆銆 from okcai_1
銆銆 where user_id = p_userId) a
銆銆 where row_id = p_col;
銆銆 return ltrim(v_tmp);
銆銆 --return v_tmp;
銆銆end;
銆銆select distinct user_id,get_col_new(user_id) from okcai_1;
銆銆49.鎬庝箞璁劇疆瀛樺偍榪囩▼鐨勮皟鐢ㄨ呮潈闄?br />銆銆鏅氬瓨鍌ㄨ繃紼嬮兘鏄墍鏈夎呮潈闄愶紝濡傛灉鎯寵緗皟鐢ㄨ呮潈闄愶紝璇峰弬鑰冨涓嬭鍙?br />銆銆create or replace
銆銆procedure ...()
銆銆AUTHID CURRENT_USER
銆銆As
銆銆begin
銆銆...
銆銆end;
銆銆50.Oracle鏈夊摢浜涘父瑙佸叧閿瓧
銆銆璇︾粏淇℃伅鍙互鏌ョ湅v$reserved_words瑙嗗浘
銆銆51.鎬庝箞鏌ョ湅鏁版嵁搴撳弬鏁?br />銆銆<1> show parameter 鍙傛暟鍚?br />銆銆濡傞氳繃show parameter spfile鍙互鏌ョ湅9i鏄惁浣跨敤spfile鏂囦歡
銆銆鍏朵腑鍙傛暟鍚嶆槸鍙互鍖歸厤鐨勩?br />銆銆姣斿show parameter cursor ,鍒欎細鏄劇ず璺焎ursor鐩稿叧鐨勫弬鏁?br />銆銆<2>
銆銆select * from v$parameter
銆銆<3>
銆銆闄や簡榪欓儴鍒嗗弬鏁幫紝Oracle榪樻湁澶ч噺闅愬惈鍙傛暟錛屽彲浠ラ氳繃濡備笅璇彞鏌ョ湅:
銆銆SELECT NAME
銆銆,VALUE
銆銆,decode(isdefault, 'TRUE','Y','N') as "Default"
銆銆,decode(ISEM,'TRUE','Y','N') as SesMod
銆銆,decode(ISYM,'IMMEDIATE', 'I',
銆銆'DEFERRED', 'D',
銆銆'FALSE', 'N') as SysMod
銆銆,decode(IMOD,'MODIFIED','U',
銆銆'SYS_MODIFIED','S','N') as Modified
銆銆,decode(IADJ,'TRUE','Y','N') as Adjusted
銆銆,description
銆銆FROM ( --GV$SYSTEM_PARAMETER
銆銆SELECT x.inst_id as instance
銆銆,x.indx+1
銆銆,ksppinm as NAME
銆銆,ksppity
銆銆,ksppstvl as VALUE
銆銆,ksppstdf as isdefault
銆銆,decode(bitand(ksppiflg/256,1),1,'TRUE','FALSE') as ISEM
銆銆,decode(bitand(ksppiflg/65536,3),
銆銆1,'IMMEDIATE',2,'DEFERRED','FALSE') as ISYM
銆銆,decode(bitand(ksppstvf,7),1,'MODIFIED','FALSE') as IMOD
銆銆,decode(bitand(ksppstvf,2),2,'TRUE','FALSE') as IADJ
銆銆,ksppdesc as DESCRIPTION
銆銆FROM x$ksppi x
銆銆,x$ksppsv y
銆銆WHERE x.indx = y.indx
銆銆AND substr(ksppinm,1,1) = '_'
銆銆AND x.inst_id = USERENV('Instance')
銆銆)
銆銆ORDER BY NAME
銆銆52.鎬庢牱寤虹珛鍩轟簬鍑芥暟绱㈠紩
銆銆8i浠ヤ笂鐗堟湰錛岀‘淇?br />銆銆Query_rewrite_enabled=true
銆銆Query_rewrite_integrity=trusted
銆銆Compatible=8.1.0浠ヤ笂
銆銆Create index indexname on table (function(field));
銆銆53.鎬庝箞鏍風Щ鍔ㄨ〃鎴栬〃鍒嗗尯
銆銆[A]縐誨姩琛ㄧ殑璇硶
銆銆Alter table tablename move
銆銆[Tablespace new_name
銆銆Storage(initial 50M next 50M
銆銆pctincrease 0 pctfree 10 pctused 50 initrans 2) nologging]
銆銆縐誨姩鍒嗗尯鐨勮娉?br />銆銆alter table tablename move (partition partname)
銆銆[update global indexes]
銆銆涔嬪悗涔嬪悗蹇呴』閲嶅緩绱㈠紩
銆銆Alter index indexname rebuild
銆銆濡傛灉琛ㄦ湁Lob孌碉紝閭d箞姝e父鐨凙lter涓嶈兘縐誨姩Lob孌靛埌鍒殑琛ㄧ┖闂達紝鑰屼粎浠呮槸縐誨姩浜嗚〃孌碉紝鍙互閲囩敤濡備笅鐨勬柟娉曠Щ鍔↙ob孌?br />銆銆alter table tablename move
銆銆lob(lobsegname) store as (tablespace newts);
銆銆54.鎬庝箞鏍蜂慨鏀硅〃鐨勫垪鍚?br />銆銆[A]9i浠ヤ笂鐗堟湰鍙互閲囩敤rname鍛戒護
銆銆ALTER TABLE UserName.TabName
銆銆RENAME COLUMN SourceColumn TO DestColumn
銆銆9i浠ヤ笅鐗堟湰鍙互閲囩敤create table 鈥︹?as select * from SourceTable鐨勬柟寮忋?br />銆銆鍙﹀錛?i浠ヤ笂鍙互鏀寔鍒犻櫎鍒椾簡
銆銆ALTER TABLE UserName.TabName
銆銆SET UNUSED (ColumnName) CASCADE CONSTRAINTS
銆銆ALTER TABLE UserName.TabName
銆銆DROP (ColumnName) CASCADE CONSTRAINTS
銆銆55.case鐨勭敤娉?br />銆銆鍦╯ql璇彞涓?br />銆銆CASE test_value
銆銆WHEN expression1 THEN value1
銆銆[[WHEN expression2 THEN value2] [...]]
銆銆[ELSE default_value]
銆銆END
銆銆姣斿1
銆銆SELECT last_name, job_id, salary
銆銆 CASE job_id
銆銆 WHEN 'IT_PROG' THEN 1.10*salary
銆銆 WHEN 'ST_CLERK' THEN 1.15*salary
銆銆 WHEN 'SA_REP' THEN 1.20*salary
銆銆 ELSE salary END "REVISED_SALARY"
銆銆FROM employees
銆銆姣斿2
銆銆select
銆銆 case
銆銆 when real_charge>=20000 and real_charge<30000 then 5000
銆銆 when real_charge>=30000 and real_charge<40000 then 9000
銆銆 when real_charge>=40000 and real_charge<50000 then 10000
銆銆 when real_charge>=50000 and real_charge<60000 then 14000
銆銆 when real_charge>=60000 and real_charge<70000 then 18000
銆銆 when real_charge>=70000 and real_charge<80000 then 19000
銆銆 when real_charge>=80000 and real_charge<90000 then 24000
銆銆 when real_charge>=90000 and real_charge<100000 then 27000
銆銆 when real_charge>=100000 and real_charge<110000 then 27000
銆銆 when real_charge>=110000 and real_charge<120000 then 29000
銆銆 when real_charge>=120000 then 36000
銆銆 else
銆銆 0
銆銆 end ,acc_id,user_id,real_charge from okcai_jh_charge_200505
銆銆鍦ㄥ瓨鍌ㄨ繃紼嬩腑
銆銆 case v_strGroupClassCode
銆銆 when '1' then
銆銆 v_nAttrNum := v_nAttrNum + 300;
銆銆 v_strAttrFlag := '1'||substr(v_strAttrFlag,2,7);
銆銆 when '2' then
銆銆 v_nAttrNum := v_nAttrNum + 200;
銆銆 v_strAttrFlag := '2'||substr(v_strAttrFlag,2,7);
銆銆 else
銆銆 NULL;
銆銆 end case;
銆銆娉ㄦ剰鐨勬槸瀛樺偍榪囩▼鍜宻ql璇彞鏈夌殑緇嗗井宸埆鏄敤end case錛岃屼笉鏄痚nd銆傝鍙ュ悗闈㈣窡";"

]]>
主站蜘蛛池模板:
国产成人免费a在线视频色戒|
在线日本高清免费不卡|
四虎影视www四虎免费|
亚洲一级黄色大片|
18勿入网站免费永久|
亚洲黄色中文字幕|
中文字幕免费在线|
亚洲精品456在线播放|
2019中文字幕免费电影在线播放
|
亚洲精品国产日韩无码AV永久免费网|
午夜毛片不卡高清免费|
亚洲中文字幕无码中文|
天天看免费高清影视|
青青草国产免费国产是公开|
久久久久无码专区亚洲av|
成人性生交大片免费看中文|
亚洲人成网址在线观看|
青草草色A免费观看在线|
亚洲日韩国产二区无码|
亚洲精品网站在线观看不卡无广告
|
成人午夜亚洲精品无码网站|
东方aⅴ免费观看久久av|
亚洲视频2020|
性感美女视频在线观看免费精品|
欧美色欧美亚洲另类二区|
亚洲女同成人AⅤ人片在线观看|
最好免费观看高清在线
|
久久精品国产亚洲AV香蕉|
国产免费av片在线看|
春意影院午夜爽爽爽免费|
久久亚洲精品成人AV|
在线精品免费视频无码的|
国产黄在线观看免费观看不卡|
亚洲综合无码一区二区|
永久黄网站色视频免费直播|
A毛片毛片看免费|
亚洲a级成人片在线观看|
亚洲综合精品网站|
一本岛高清v不卡免费一三区|
成人午夜免费视频|
亚洲午夜精品在线|