DBA 작업 상용 명령
16701 단어 상용 명령
、ORACLE
1、
ORACLE ORACLE ,
su - oracle
a、 ORACLE
oracle>svrmgrl
SVRMGR>connect internal
SVRMGR>startup
SVRMGR>quit
b、 ORACLE
oracle>svrmgrl
SVRMGR>connect internal
SVRMGR>shutdown
SVRMGR>quit
oracle9i :
$ sqlplus /nolog
SQL*Plus: Release 9.2.0.1.0 - Production on Fri Oct 31 13:53:53 2003
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup^C
SQL> startup
ORACLE instance started.
2、
ORACLE root ,
su - root
a、 ORACLE
hareg -y oracle
b、 ORACLE
hareg -n oracle
Oracle
:
:
1、startup nomount
, : 、
init.ora , instance, SGA , init.ora 。
2、startup mount dbname
, :
、
、
,
、 。
“nomount”, , ,
。
3、startup open dbname
“nomount”, “mount”, Redo log ,
。
4、startup,
startup nomount
alter database mount
alter database open
5、startup restrict
,
, :
ERROR:
ORA-01035: ORACLE RESTRICTED SESSION
6、startup force
, startup force
,
7、startup pfile=
,
:startup pfile=E:Oracleadminoradbpfileinit.ora
8、startup EXCLUSIVE
、
ORACLE , , ,
sys 。 。
、 、 、 、 。
。
, ORACLE 。
dictionary , dict
dict_column
, SQL :
SQL>select * from dictionary where instr(comments,'index')>0;
user_indexes , SQL :
SQL>select column_name,comments from dict_columns where table_name='USER_INDEXES';
, , ORACLE 。
ORACLE 。
1、
SQL>select username,default_tablespace from user_users;
SQL>select * from user_role_privs;
SQL>select * from user_sys_privs;
SQL>select * from user_tab_privs;
2、
SQL>select * from user_tables;
log
SQL>select object_name,object_id from user_objects
where instr(object_name,'LOG')>0;
SQL>select object_name,created from user_objects where object_name=upper('&table_name');
SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segments
where segment_name=upper('&table_name');
ORACLE
SQL>select table_name,cache from user_tables where instr(cache,'Y')>0;
3、
SQL>select index_name,index_type,table_name from user_indexes order by table_name;
SQL>select * from user_ind_columns where index_name=upper('&index_name');
SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segments
where segment_name=upper('&index_name');
4、
,last_number
SQL>select * from user_sequences;
5、
SQL>select view_name from user_views;
select
SQL>set view_name,text_length from user_views;
SQL>set long 2000; : text_length set long
SQL>select text from user_views where view_name=upper('&view_name');
6、
SQL>select * from user_synonyms;
7、
SQL>select constraint_name, constraint_type,search_condition, r_constraint_name
from user_constraints where table_name = upper('&table_name');
SQL>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;
8、
SQL>select object_name,status from user_objects where object_type='FUNCTION';
SQL>select object_name,status from user_objects where object_type='PROCEDURE';
SQL>select text from all_source where owner=user and name=upper('&plsql_name');
、 SQL
1、
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2、
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;
3、
select segment_name, tablespace_name, r.status,
(initial_extent/1024) InitialExtent,(next_extent/1024) NextExtent,
max_extents, v.curext CurExtent
From dba_rollback_segs r, v$rollstat v
Where r.segment_id = v.usn(+)
order by segment_name ;
4、
select name from v$controlfile;
5、
select member from v$logfile;
6、
select sum(bytes)/(1024*1024) as free_space,tablespace_name
from dba_free_space
group by tablespace_name;
SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,
(B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"
FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;
7、
select owner, object_type, status, count(*) count# from all_objects group by owner, object_type, status;
8、
Select version FROM Product_component_version
Where SUBSTR(PRODUCT,1,6)='Oracle';
9、
Select Created, Log_Mode, Log_Mode From V$Database;
、ORACLE
, :
SQL> select username,sid,serial# from v$session;
SQL> alter system kill session 'sid,serial#';
, UNIX
SQL> select pro.spid from v$session ses,v$process pro where ses.sid=21 and ses.paddr=pro.addr;
:21 sid
kill 。
、SQL*PLUS
a、 SQL*Plus
$sqlplus /
SQL*Plus
SQL>exit
b、 sqlplus
SQL SQL*Plus
SQL>help
SQL>help
c、 DESCRIBE
SQL>DESC
d、SQL*Plus
SQL
SQL>L
SQL
SQL>n
CHANGE
SQL>c/ /
SQL>L
INPUT SQL
SQL>i
SQL>
e、
SQL>edit
DEFINE EDITOR , login.sql
DEFINE_EDITOR=vi
f、
SQL>START test
SQL>@test
SQL*Plus
a、 、 、
:
create table ( );
:
ALTER TABLE ADD ( )
: test Age,
sql>alter table test
add (Age number(3));
:
ALTER TABLE
MODIFY ( )
: test Count 10
sql>alter atble test
modify (County char(10));
b、 :
DORP TABLE ;
:
sql>drop table test
c、 、
、ORACLE SH
SH :exp_comp.sh
rq=` date +"%m%d" `
su - oracle -c "exp system/manager full=y inctype=complete file=/oracle/export/db_comp$rq.dmp"
SH :exp_cumu.sh
rq=` date +"%m%d" `
su - oracle -c "exp system/manager full=y inctype=cumulative file=/oracle/export/db_cumu$rq.dmp"
SH : exp_incr.sh
rq=` date +"%m%d" `
su - oracle -c "exp system/manager full=y inctype=incremental file=/oracle/export/db_incr$rq.dmp"
root crontab
/var/spool/cron/crontabs/root
0 2 1 * * /oracle/exp_comp.sh
30 2 * * 0-5 /oracle/exp_incr.sh
45 2 * * 6 /oracle/exp_cumu.sh
, 。
、ORACLE SQL
. (DML)
1.INSERT ( )
INSERT INTO ( 1, 2, ……) VALUES ( 1, 2, ……);
INSERT INTO ( 1, 2, ……) SELECT ( 1, 2, ……) FROM ;
, : ’GOOD DAY’
’ , '.
, .
SYSDATE,
TO_DATE(‘2001-08-01’,’YYYY-MM-DD’)
TO_DATE() , ORACLE DOC.
- - : : YYYY-MM-DD HH24:MI:SS
INSERT 4000 , , CLOB ,
ORACLE DBMS_LOB .
INSERT 1 ,
CREATE SEQUENCE ( + ) INCREMENT BY 1 START WITH 1
MAXVALUE 99999 CYCLE NOCACHE;
, NUMBER(6) , 999999
INSERT : .NEXTVAL
2.DELETE ( )
DELETE FROM WHERE ;
: ORACLE . unused.
, TRUNCATE ,
TRUNCATE TABLE ;
.
3.UPDATE ( )
UPDATE SET 1= 1, 2= 2, …… WHERE ;
N , NULL, ;
N , ..
:
A. SQL ,
, COMMIT ,
.
, ROLLBACK .
B. INSERT, DELETE UPDATE ,
( ) ,. ORACLE .
. , SQL ,
COMMIT .
. (DDL)
1.CREATE ( , , , , , , )
ORACLE
CHAR
VARCHAR2
NUMBER(M,N) M , N
DATE
,
,
, DEFAULT SYSDATE
,
UNIQUE, PRIMARY KEY
2.ALTER ( , , )
ALTER TABLE 1 TO 2;
ALTER TABLE ADD ;
ALTER TABLE MODIFY ;
ALTER TABLE ADD CONSTRAINT PRIMARY KEY ( );
ALTER TABLE ADD CONSTRAINT UNIQUE ( );
ALTER TABLE CACHE;
ALTER TABLE NOCACHE;
3.DROP ( , , , , , , )
DROP TABLE CASCADE CONSTRAINTS;
4.TRUNCATE ( , )
TRUNCATE ;
. (SELECT)
SELECT 1, 2, …… FROM 1, [ 2, ……] WHERE ;
: COUNT(*), MIN( ), MAX( ), AVG( ), DISTINCT( ),
TO_CHAR(DATE ,'YYYY-MM-DD HH24:MI:SS')
NVL(EXPR1, EXPR2)
:
IF EXPR1=NULL
RETURN EXPR2
ELSE
RETURN EXPR1
DECODE(AA﹐V1﹐R1﹐V2﹐R2....)
:
IF AA=V1 THEN RETURN R1
IF AA=V2 THEN RETURN R2
..…
ELSE
RETURN NULL
LPAD(char1,n,char2)
:
char1 n , char2
: ( 1* 1)/3
: SELECT …… FROM
(SELECT …… FROM 1, [ 2, ……] WHERE ) WHERE 2;
: UNION( ), UNION ALL( ), MINUS, INTERSECT
SELECT 1, 2, …… FROM 1, [ 2, ……] GROUP BY 1
[HAVING ] ;
SELECT 1, 2, …… FROM 1, [ 2, ……] WHERE
1. = 2. [ AND ……] ;
SELECT 1, 2, …… FROM 1, [ 2, ……] WHERE
1. = 2. (+) [ AND ……] ;
(+)
, ASC, DESC
SELECT 1, 2, …… FROM 1, [ 2, ……]
ORDER BY 1, 2 DESC;
INSTR( , ‘ ’)>0
LIKE ‘ %’ [‘% %’]
ROWID, .
.ORACLE (SCHEMA)
1. (INDEX)
CREATE INDEX ON ( 1, [ 2, ……] ;
ALTER INDEX REBUILD;
( ), , SQL ,
ORACLE8.1.7 1578
ORACLE8.0.6 758
2. (VIEW)
CREATE VIEW AS SELECT …. FROM …..;
ALTER VIEW COMPILE;
SQL , .
3. (SYNONMY)
CREATE SYNONYM FOR ;
CREATE SYNONYM FOR @ ;
4. (DATABASE LINK)
CREATE DATABASE LINK CONNECT TO IDENTIFIED BY USING ‘ ’;
NET8 EASY CONFIG TNSNAMES.ORA .
global_name=true
SELECT * FROM GLOBAL_NAME;
SELECT …… FROM @ ;
. (DCL)
1.GRANT
:
CONNECT( ), RESOURCE( ), DBA( )
:
ALL ON , SELECT ON , UPDATE ON ,
DELETE ON , INSERT ON , ALTER ON
GRANT CONNECT, RESOURCE TO ;
GRANT SELECT ON TO ;
GRANT SELECT, INSERT, DELETE ON TO 1, 2;
2.REVOKE
REVOKE CONNECT, RESOURCE FROM ;
REVOKE SELECT ON FROM ;
REVOKE SELECT, INSERT, DELETE ON FROM 1, 2;
63 :
select orgaddr,destaddr from sm_histable0116 where error_code='63';
: select MSISDN,TCOS,OCOS from ms_usertable;
:
select error_code,count(*) from sm_histable0513 group by error_code order
by error_code;
。
select sum(Successcount) from tbl_MiddleMt0411 where ServiceType2=111
select sum(successcount),servicetype from tbl_middlemt0411 group by servicetype
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
DBA 작업 상용 명령텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.