锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
鏁版嵁瀛楀吀dict鎬繪槸灞炰簬Oracle鐢ㄦ埛sys鐨勩?
銆銆1銆佺敤鎴鳳細
銆銆銆select username from dba_users;
銆銆鏀瑰彛浠?
銆銆銆alter user spgroup identified by spgtest;
銆銆2銆佽〃絀洪棿錛?
銆銆銆select * from dba_data_files;
銆銆銆select * from dba_tablespaces;//琛ㄧ┖闂?
銆銆銆select tablespace_name,sum(bytes), sum(blocks)
銆銆銆銆from dba_free_space group by tablespace_name;//絀洪棽琛ㄧ┖闂?
銆銆銆select * from dba_data_files
銆銆銆銆where tablespace_name='RBS';//琛ㄧ┖闂村搴旂殑鏁版嵁鏂囦歡
銆銆銆select * from dba_segments
銆銆銆銆where tablespace_name='INDEXS';
銆銆3銆佹暟鎹簱瀵硅薄錛?
銆銆銆select * from dba_objects;
銆銆銆CLUSTER銆丏ATABASE LINK銆丗UNCTION銆両NDEX銆丩IBRARY銆丳ACKAGE銆丳ACKAGE BODY銆?
銆銆銆PROCEDURE銆丼EQUENCE銆丼YNONYM銆乀ABLE銆乀RIGGER銆乀YPE銆乁NDEFINED銆乂IEW銆?
銆銆4銆佽〃錛?
銆銆銆select * from dba_tables;
銆銆銆analyze my_table compute statistics;->dba_tables鍚?鍒?
銆銆銆select extent_id,bytes from dba_extents
銆銆銆where segment_name='CUSTOMERS' and segment_type='TABLE'
銆銆銆order by extent_id;//琛ㄤ嬌鐢ㄧ殑extent鐨勪俊鎭俿egment_type='ROLLBACK'鏌ョ湅鍥炴粴孌電殑絀洪棿鍒嗛厤淇℃伅
銆銆銆鍒椾俊鎭細
聽聽聽聽聽聽聽聽聽聽聽聽聽<1>.
銆銆銆銆select distinct table_name
銆銆銆銆from user_tab_columns
銆銆銆銆where column_name='SO_TYPE_ID';聽
聽聽聽聽聽聽聽聽聽聽聽聽<2>.
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽鏌ヨ琛ㄧ殑鍒楀悕銆佹敞閲娿佺被鍨嬨侀暱搴?br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽select a.table_name,a.COLUMN_NAME,b.COMMENTS,a.DATA_TYPE,a.DATA_LENGTH
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽from user_tab_columns a,user_col_comments b
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽where a.table_NAME = b.table_NAME
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽and a.COLUMN_NAME = b.COLUMN_NAME
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽and a.TABLE_NAME = 'table_name';
聽聽聽聽聽聽聽聽聽聽聽聽
銆銆5銆佺儲寮曪細銆
銆銆銆select * from dba_indexes;//绱㈠紩錛屽寘鎷富閿儲寮?
銆銆銆select * from dba_ind_columns;//绱㈠紩鍒?
銆銆銆select i.index_name,i.uniqueness,c.column_name
銆銆銆銆from user_indexes i,user_ind_columns c
銆銆銆銆銆where i.index_name=c.index_name
銆銆銆銆銆and i.table_name ='ACC_NBR';//鑱旀帴浣跨敤
銆銆6銆佸簭鍒楋細
銆銆銆select * from dba_sequences;
銆銆7銆佽鍥撅細
銆銆銆select * from dba_views;
銆銆銆select * from all_views;
銆銆text 鍙敤浜庢煡璇㈣鍥劇敓鎴愮殑鑴氭湰
銆銆8銆佽仛綈囷細
銆銆銆select * from dba_clusters;
銆銆9銆佸揩鐓э細
銆銆銆select * from dba_snapshots;
銆銆蹇収銆佸垎鍖哄簲瀛樺湪鐩稿簲鐨勮〃絀洪棿銆?
銆銆10銆佸悓涔夎瘝錛?
銆銆銆select * from dba_synonyms
銆銆銆銆where table_owner='SPGROUP';
銆銆銆銆//if owner is PUBLIC,then the synonyms is a public synonym.
銆銆銆銆銆if owner is one of users,then the synonyms is a private synonym.
銆銆11銆佹暟鎹簱閾撅細
銆銆銆select * from dba_db_links;
銆銆鍦╯pbase涓嬪緩鏁版嵁搴撻摼
銆銆銆create database link dbl_spnew
銆銆銆connect to spnew identified by spnew using 'jhhx';
銆銆銆insert into
acc_nbr@dbl_spnew
銆銆銆select * from acc_nbr where nxx_nbr='237' and line_nbr='8888';
銆銆12銆佽Е鍙戝櫒錛?
銆銆銆select * from dba_trigers;
銆銆瀛樺偍榪囩▼錛屽嚱鏁頒粠dba_objects鏌ユ壘銆?
銆銆鍏舵枃鏈細select text from user_source where name='BOOK_SP_EXAMPLE';
銆銆寤虹珛鍑洪敊錛歴elect * from user_errors;
銆銆oracle鎬繪槸灝嗗瓨鍌ㄨ繃紼嬶紝鍑芥暟絳夎蔣浠舵斁鍦⊿YSTEM琛ㄧ┖闂淬?
銆銆13銆佺害鏉燂細
銆銆錛?錛夌害鏉熸槸鍜岃〃鍏寵仈鐨勶紝鍙湪create table鎴朼lter table table_name add/drop/modify鏉ュ緩绔嬨佷慨鏀廣佸垹闄ょ害鏉熴?
銆銆鍙互涓存椂紱佹綰︽潫錛屽錛?
銆銆銆alter table book_example
銆銆銆disable constraint book_example_1;
銆銆銆alter table book_example
銆銆銆enable constraint book_example_1;
銆銆錛?錛変富閿拰澶栭敭琚О涓鴻〃綰︽潫錛岃宯ot null鍜寀nique涔嬬被鐨勭害鏉熻縐頒負鍒楃害鏉熴傞氬父灝嗕富閿拰澶栭敭浣滀負鍗曠嫭鐨勫懡鍚嶇害鏉熸斁鍦ㄥ瓧孌靛垪琛ㄤ笅闈紝鑰屽垪綰︽潫鍙斁鍦ㄥ垪瀹氫箟鐨勫悓涓琛岋紝榪欐牱鏇村叿鏈夊彲璇繪с?
銆銆錛?錛夊垪綰︽潫鍙粠琛ㄥ畾涔夌湅鍑猴紝鍗砫escribe;琛ㄧ害鏉熷嵆涓婚敭鍜屽閿紝鍙粠dba_constraints鍜宒ba_cons_columns 鏌ャ?
銆銆銆select * from user_constraints
銆銆銆where table_name='BOOK_EXAMPLE';
銆銆銆select owner,CONSTRAINT_NAME,TABLE_NAME
銆銆銆銆from user_constraints
銆銆銆銆where constraint_type='R'
銆銆銆銆order by table_name;
銆銆錛?錛夊畾涔夌害鏉熷彲浠ユ棤鍚嶏紙緋葷粺鑷姩鐢熸垚綰︽潫鍚嶏級鍜岃嚜宸卞畾涔夌害鏉熷悕錛堢壒鍒槸涓婚敭銆佸閿級
銆銆濡傦細create table book_example
銆銆銆銆(identifier number not null);
銆銆銆銆create table book_example
銆銆銆銆(identifier number constranit book_example_1 not null);
銆銆14銆佸洖婊氭錛?
銆銆鍦ㄦ墍鏈夌殑淇敼緇撴灉瀛樺叆紓佺洏鍓嶏紝鍥炴粴孌典腑淇濇寔鎭㈠璇ヤ簨鍔℃墍闇鐨勫叏閮ㄤ俊鎭紝蹇呴』浠ユ暟鎹簱鍙戠敓鐨勪簨鍔℃潵鐩稿簲紜畾鍏跺ぇ灝忥紙DML璇彞鎵嶅彲鍥炴粴錛宑reate,drop,truncate絳塂DL涓嶈兘鍥炴粴錛夈?
銆銆鍥炴粴孌墊暟閲?騫跺彂浜嬪姟/4錛屼絾涓嶈兘瓚呰繃50錛涗嬌姣忎釜鍥炴粴孌靛ぇ灝忚凍澶熷鐞嗕竴涓畬鏁寸殑浜嬪姟錛?
銆銆銆create rollback segment r05
銆銆銆tablespace rbs;
銆銆銆create rollback segment rbs_cvt
銆銆銆tablespace rbs
銆銆銆storage(initial 1M next 500k);
銆銆浣垮洖婊氭鍦ㄧ嚎
銆銆銆alter rollback segment r04 online;
銆銆鐢╠ba_extents,v$rollback_segs鐩戞祴鍥炴粴孌電殑澶у皬鍜屽姩鎬佸闀褲?
銆銆鍥炴粴孌電殑鍖洪棿淇℃伅
銆銆銆select * from dba_extents
銆銆銆where segment_type='ROLLBACK' and segment_name='RB1';
銆銆鍥炴粴孌電殑孌典俊鎭?鍏朵腑bytes鏄劇ず鐩墠鍥炴粴孌電殑瀛楄妭鏁?
銆銆銆select * from dba_segments
銆銆銆銆where segment_type='ROLLBACK' and segment_name='RB1';
銆銆涓轟簨鐗╂寚瀹氬洖褰掓
銆銆銆set transaction use rollback segment rbs_cvt
銆銆閽堝bytes鍙互浣跨敤鍥炴粴孌靛洖緙┿?
銆銆銆alter rollback segment rbs_cvt shrink;
銆銆銆select bytes,extents,max_extents from dba_segments
銆銆銆銆where segment_type='ROLLBACK' and segment_name='RBS_CVT';
銆銆鍥炴粴孌電殑褰撳墠鐘舵佷俊鎭細
銆銆銆select * from dba_rollback_segs
銆銆銆銆where segment_name='RB1';
銆銆姣斿鍥炴粴孌電姸鎬乻tatus錛屽洖婊氭鎵灞炲疄渚媔nstance_num
銆銆鏌ヤ紭鍖栧紀ptimal
銆銆銆select n.name,s.optsize
銆銆銆銆from v$rollname n,v$rollstat s
銆銆銆銆銆where n.usn=s.usn;
銆銆鍥炴粴孌典腑鐨勬暟鎹?
銆銆銆set transaction use rollback segment rb1;/*鍥炴粴孌靛悕*/
銆銆銆select n.name,s.writes
銆銆銆銆from v$rollname n,v$rollstat s
銆銆銆銆銆where n.usn=s.usn;
銆銆褰撲簨鍔″鐞嗗畬姣曪紝鍐嶆鏌ヨ$rollstat錛屾瘮杈僿rites(鍥炴粴孌墊潯鐩瓧鑺傛暟)宸鹼紝鍙‘瀹氫簨鍔$殑澶у皬銆?
銆銆鏌ヨ鍥炴粴孌典腑鐨勪簨鍔?
銆銆銆column rr heading 'RB Segment' format a18
銆銆銆column us heading 'Username' format a15
銆銆銆column os heading 'Os User' format a10
銆銆銆column te heading 'Terminal' format a10
銆銆銆select r.name rr,nvl(s.username,'no transaction') us,s.osuser os,s.terminal te
銆銆銆銆from v$lock l,v$session s,v$rollname r
銆銆銆銆銆where l.sid=s.sid(+)
銆銆銆銆銆and trunc(l.id1/65536)=R.USN
銆銆銆銆銆and l.type='TX'
銆銆銆銆銆and l.lmode=6
銆銆銆order by r.name;
銆銆15銆佷綔涓?
銆銆鏌ヨ浣滀笟淇℃伅
銆銆銆select job,broken,next_date,interval,what from user_jobs;
銆銆銆select job,broken,next_date,interval,what from dba_jobs;
銆銆鏌ヨ姝e湪榪愯鐨勪綔涓?
銆銆銆select * from dba_jobs_running;
銆銆浣跨敤鍖卐xec dbms_job.submit(:v_num,'a;',sysdate,'sysdate + (10/(24*60*60))')鍔犲叆浣滀笟銆傞棿闅?0縐掗挓
聽聽聽 exec dbms_job.submit(:v_num,'a;',sysdate,'sysdate + (11/(24*60))')鍔犲叆浣滀笟銆傞棿闅?1鍒嗛挓浣跨敤鍖卐xec dbms_job.remove(21)鍒犻櫎21鍙蜂綔涓氥?br />
......
String exSQL = " SELECT * FROM PK_TEST WHERE ID = ?";
pstmt = conn.prepareStatement(exSQL);
pstmt.setString(1,idValue);
ResultSet rs = pstmt.executeQuery();
......
鍏朵腑PK_TEST緇撴瀯濡備笅錛?/FONT>
CREATE TABLE PK_TEST (
ID CHAR (9) NOT NULL,
NAME VARCHAR2 (40),
GENDER CHAR (1),
CONSTRAINT PK_PK_TEST
PRIMARY KEY ( ID ) ) ;
娉ㄦ剰錛欼D鏄疌HAR (9)
鍦ㄨ〃涓彃鍏ユ祴璇曟暟鎹細
INSERT INTO PK_TEST ( ID, NAME, GENDER ) VALUES ('1 ', 'test1', '1');
INSERT INTO PK_TEST ( ID, NAME, GENDER ) VALUES ('2 ', 'test2', '0');
INSERT INTO PK_TEST ( ID, NAME, GENDER ) VALUES ('3 ', 'test3', '1');
INSERT INTO PK_TEST ( ID, NAME, GENDER ) VALUES ('123456789', 'test4', '0');
INSERT INTO PK_TEST ( ID, NAME, GENDER ) VALUES ('987654321', 'test5', '1');
浣跨敤Toad鎵ц:
SELECT * FROM PK_TEST WHERE ID ='1';
SELECT * FROM PK_TEST WHERE ID ='1 ';
閮芥病鏈夐棶棰橈紝浣嗗鏋滄垜灝嗗墠闈ava璇硶pstmt.setString(1,idValue);涓殑idValue璧嬪間負'1'錛岀▼搴忓氨鏄彇涓嶅埌鍊鹼紱
緇х畫嫻嬭瘯錛?BR>SELECT * FROM PK_TEST WHERE ID = :ID;
璧嬪間負'1'錛屾病鏈夌粨鏋滐紱
璧嬪間負'1 '錛岀粨鏋滃嚭鏉ヤ簡錛?/FONT>
鍙鏃犺鍦╦dbc榪樻槸鍦ㄦ暟鎹簱涓蔣緙栫爜鍜岀‖緙栫爜鏈変竴瀹氱殑鍖哄埆銆?/FONT>
鍞夛紒鏁寸悊鏁版嵁搴撲腑鐨勪富閿惂錛欼D = SUBSTR(TRIM(ID)||'000000000',0,9);
sqlplus /nolog
connect system/manager@SID as sysdba
startup
shutdown