# 建立用戶
create user angeos identified by angeos;
建立了用戶:angeos,密碼為:angeos
# 對(duì)用戶授權(quán)
grant connect,resource to angeos;
對(duì)用戶angeos授予了連接數(shù)據(jù)庫(kù)和訪問(wèn)資源的權(quán)限
# 對(duì)用戶授權(quán)
grant create session,dba to angeos;
CREATE SESSION是一個(gè)系統(tǒng)特權(quán),它可以為用戶提供連接數(shù)據(jù)庫(kù)的能力。
DBA是一個(gè)具有超過(guò)120個(gè)系統(tǒng)特權(quán)的角色,所以它可以讓用戶在數(shù)據(jù)庫(kù)中完成幾乎任何工作。
# 改變用戶的密碼
alter user angeos identified by oracle;
將用戶angeos的密碼改變?yōu)椋簅racle
# 鎖定帳號(hào)以及解鎖
alter user oe account unlock;
然后用用戶oe登錄數(shù)據(jù)庫(kù)服務(wù)器,密碼為oe
注意:用戶解鎖后,要重啟服務(wù)。
# 修改表空間的設(shè)置
默認(rèn)情況下,它會(huì)使用表空間SYSTEM和TEMP(用于存放臨時(shí)數(shù)據(jù))。
不推薦采用這種方法。所以我們需要改變表空間。
通過(guò)系統(tǒng)用戶連接數(shù)據(jù)庫(kù)服務(wù)器
conn sys/lx as sysdba;
然后查看表空間
select tablespace_name,contents from dba_tablespaces
order by tablespace_name;
使用USER表空間代替SYSTEM表空間
alter user angeos default tablespace users
temporary tablespace temp;
#創(chuàng)建表空間
create tablespace hhus datafile '\home\oracle\orabase\oradata\ORACLE\hhus.dbf' size 500M;
create user hhus identified by hhus default tablespace hhus;
這樣就創(chuàng)建了表空間,使用表空間即用上面的語(yǔ)句
說(shuō)明一下:tablespace hhus表空間是hhus 里面'單引號(hào)'是oracle路徑下的文件,hhus.dbf可以隨便起名
一個(gè)用戶訪問(wèn)兩個(gè)表空間:
alter user 用戶 quota unlimited on 表空間A;
alter user 用戶 quota unlimited on 表空間B;
或者放開所有表空間
grant unlimited tablespace to 用戶;
或者索性給所有權(quán)限
grant resource,connect,dba to 用戶;
擴(kuò)展表空間語(yǔ)句:(解決ORA-01659: unable to allocate MINEXTENTS beyond 1 in tablespace HHPACS的問(wèn)題)
alter database datafile '/app/oracle/oradata/oracle/hhpacs.dbf' autoextend on;
其中的hhpacs.dbf一定要一致
select count(*) from v$process --查詢當(dāng)前的連接數(shù)
select value from v$parameter where name = 'processes' --數(shù)據(jù)庫(kù)允許的最大連接數(shù)
修改最大連接數(shù):
alter system set processes = 300 scope = spfile;
重啟數(shù)據(jù)庫(kù):
shutdown immediate;
startup;
--查看當(dāng)前有哪些用戶正在使用數(shù)據(jù)
SELECT osuser, a.username,cpu_time/executions/1000000||'s', sql_fulltext,machine
from v$session a, v$sqlarea b
where a.sql_address =b.address order by cpu_time/executions desc;
查詢當(dāng)前數(shù)據(jù)庫(kù)服務(wù)端字符集:
select userenv('language') from dual;
修改數(shù)據(jù)庫(kù)服務(wù)端字符集:
修改成AMERICAN_AMERICA.US7ASCII
除了上述查看服務(wù)端字符集外還可以使用以下3句sql
select * from v$nls_parameters;
select * from nls_database_parameters;
select * from sys.props$;
使用sys用戶登錄:
update props$ set value$='US7ASCII' where name = 'NLS_CHARACTERSET';
update props$ set value$='AMERICAN_AMERICA' where name='NLS_LANGUAGE';
最后shutdown immediate;
接著startup
再進(jìn)行select userenv('language') from dual;
即可看到字符集為:AMERICAN_AMERICA.US7ASCII
使用網(wǎng)上流傳的第二種方法:
首先sys用戶登錄
alter system enable restricted session
alter database ORACLE character set US7ASCII
alter database national character set US7ASCII
如果用PLSQL或者DOS窗口遠(yuǎn)程連接數(shù)據(jù)庫(kù)就會(huì)報(bào)一些:監(jiān)聽程序: 所有適用例程都處于受限模式 或者 適配器協(xié)議錯(cuò)誤 或者 當(dāng)前操作無(wú)法進(jìn)行因?yàn)橛谢顒?dòng)的session等等。。。。
遇見以上問(wèn)題:
必須要在ORACLE所在機(jī)器上進(jìn)行操作(我的是linux)
打開終端:
輸入sqlplus /nolog
接著connect sys/密碼 提示連接成功 (不會(huì)出現(xiàn)適配器協(xié)議錯(cuò)誤的提示)
alter system disable restricted session 這句sql即可清除 監(jiān)聽程序: 所有適用例程都處于受限模式的錯(cuò)誤
posted on 2010-09-08 20:46
朔望魔刃 閱讀(748)
評(píng)論(0) 編輯 收藏 所屬分類:
數(shù)據(jù)庫(kù)