您好,登錄后才能下訂單哦!
查看oracle版本
select banner from sys.v_$version;
-------------------------------------
查看不同用戶的連接數(shù)
select username,count(username) from v$session where username is not null group by username;
-------------------------------------
查詢oracle的并發(fā)連接數(shù)
select count(*) from v$session where status='ACTIVE';
--------------------------------------
Oracle數(shù)據(jù)庫(kù)中表的導(dǎo)入導(dǎo)出操作:
以Windows下的數(shù)據(jù)庫(kù)為例(用cmd方式):
導(dǎo)出表:
1.導(dǎo)出整個(gè)數(shù)據(jù)庫(kù)
exp 導(dǎo)表的用戶名/密碼@實(shí)例名 file='E:\xxx.dmp' full=y
2.導(dǎo)出單表或多表
exp 導(dǎo)表的用戶名/密碼@實(shí)例名 file='E:\xxx.dmp' tables=t1[(t1,t2,t3)]
3.導(dǎo)出數(shù)據(jù)庫(kù)中一個(gè)或多個(gè)用戶下的表
exp 導(dǎo)表的用戶名/密碼@實(shí)例名 file='E:\xxx.dmp' owner=(system,sys)
4.將數(shù)據(jù)庫(kù)中的表table1中的字段filed1以"00"打頭的數(shù)據(jù)導(dǎo)出
exp 導(dǎo)表的用戶名/密碼@實(shí)例名 file='E:\xxx.dmp' tables=(table1) query=\" where filed1 like '00%'\"
------------------------------------------
導(dǎo)入表:
將E:\xxx.dmp 中的數(shù)據(jù)導(dǎo)入某數(shù)據(jù)庫(kù)中。
imp 導(dǎo)表的用戶名/密碼@實(shí)例名 file=e:\xxx.dmp
imp 導(dǎo)表的用戶名/密碼@實(shí)例名 full=y file=e:\xxx.dmp ignore=y
在后面加上 ignore=y 忽略導(dǎo)入的報(bào)錯(cuò),直接導(dǎo)入。
2 將e:\xxx.dmp中的表table1 導(dǎo)入
imp 導(dǎo)表的用戶名/密碼@實(shí)例名 file=e:\xxx.dmp tables=(table1)
----------------------------
Linux的話直接exp,imp根據(jù)提示操作,效果也是一樣的。如果通過語句,可以現(xiàn)在emedit上寫好直接復(fù)制黏貼即可。
---------------------------
數(shù)據(jù)庫(kù)中查看版本:
select * from v$version;
Linux下查看ORACLE版本信息:
file $ORACLE_HOME/bin/oracle
-------------------------
數(shù)據(jù)庫(kù)服務(wù)器查看字符集:
select * from nls_database_parameters;
其中NLS_CHARACTERSET下面的就是該數(shù)據(jù)庫(kù)服務(wù)器的字符集
-------------------------
查看表空間xxx使用情況:(需sysdba權(quán)限):
select /*+ ordered use_merge(a,b) */
a.tablespace_name 表空間名,
total/(1024*1024) 表空間大小,
(total-free)/(1024*1024) 表空間使用大小,
free/(1024*1024) 表空間剩余大小,
round((total-free)/total,4)*100 "使用率%"
from (select tablespace_name,sum(bytes) free from dba_free_space
group by tablespace_name) a,
(select tablespace_name,sum(bytes) total from dba_data_files
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
and a.tablespace_name = 'xxx';
-------------------------
查看當(dāng)前用戶下的表空間:(非sysdba)
select
a.bytes/1024/1024 "used(MB)",
b.bytes/1024/1024 "free(MB)",
a.bytes/1024/1024+b.bytes/1024/1024 "total(MB)"
from user_ts_quotas a,user_free_space b
where a.TABLESPACE_NAME=b.TABLESPACE_NAME and a.TABLESPACE_NAME='XXX';
-------------------------
查看當(dāng)前角色XXX所具有的權(quán)限:
select * from dba_sys_privs where grantee='XXX';
-------------------------
查看當(dāng)前用戶所具有的角色:
select * from user_role_privs;
select * from session_privs;
-------------------------
查看當(dāng)前用戶的系統(tǒng)權(quán)限和表級(jí)權(quán)限
select * from user_sys_privs;
select * from user_tab_privs;
-------------------------
查看哪些用戶具有sysdba或sysooper權(quán)限:
select * from V$PWFILE_USERS;
-------------------------
查看用戶為XXX的表空間配額。(-1為不受限制)
select tablespace_name,username,max_bytes from DBA_TS_QUOTAS where username='XXX';
-------------------------
設(shè)定用戶mc的表空間配額限為100M:
alter user mc quota 100M on tablespacname;
-------------------------
設(shè)定用戶mc的表空間配額為無限制:
alter user mc quota unlimited on tablespacname;
-------------------------
賦予用戶mc配置表空間無限額的權(quán)限:
grant unlimited tablespace to mc;
-------------------------
查看當(dāng)前數(shù)據(jù)庫(kù)的實(shí)例名:
select instance_name from v$instance;
-------------------------
修改用戶表空間和臨時(shí)表空間:
ALTER USER SCOTT DEFAULT TABLESPACE USERS;
ALTER USER SCOTT TEMPORARY TABLESPACE TEMP;
-------------------------
查看當(dāng)前用戶缺省的表空間:
select username,default_tablespace from user_users;
--------------------------------
查看歸檔是否開啟;開啟/關(guān)閉歸檔:
--------------
查看歸檔:
sqlplus>archive log list;
開啟歸檔
sqlplus>shutdown immediate;(啟動(dòng)歸檔前先要停止數(shù)據(jù)庫(kù))
sqlplus>startup mount;(數(shù)據(jù)庫(kù)以mount方式啟動(dòng))
sqlplus>alter database archivelog;(啟動(dòng)數(shù)據(jù)庫(kù)歸檔)
sqlplus>alter system set log_archive_dest_1="/arch"(改變路徑,使用盤符)
sqlplus>alter database open;(打開數(shù)據(jù)庫(kù))
sqlplus>archive log list;(查看歸檔是否已經(jīng)打開)
關(guān)閉歸檔
alter database noarchivelog;
--------------
查看歸檔日志使用情況:
select * from v$flash_recovery_area_usage;
-----------------------
查看用戶賬戶狀態(tài):
select username,account_status from dba_users where username in ('DBSNMP','SYSMAN');
----------------------------
查看REDO日志位置、狀態(tài),以及添加、刪除REDO日志組方法:
位置:
select * form v$logfile;
狀態(tài):
select group#,thread#,bytes/1024/1024,status from v$log;
:添加
alter database add logfile group 1|2|3|4('/u01/oracle/oradata/mcocp/redo01|02|03|04') size 100m;
刪除:
alter database drop logfile group 1|2|3|4;
注:oracle11g默認(rèn)的redo logsize為50M
----------------------------------------
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。