1. 程式人生 > >Oracle常見問題彙總

Oracle常見問題彙總

create user testuser identified by test default tablespace indx;//建立使用者
 grant resource,create session,connect to testuser;//授權

scott使用者解鎖:ORA-28000: the account is locked-的解決辦法

1 Dos下輸入C:sqlplus /nolog

2 以DBA的身份登入
      conn sys/password as sysdba;
3 解鎖
      alter user scott account unlock;
4 彈出一個修改密碼的對話方塊,修改密碼
      conn scott/tiger

SQL> conn sys/sys as sysdba;
      Connected.
SQL> alter user scott account unlock;
      User altered.
SQL> commit;
      Commit complete.
SQL> conn scott/tiger//請輸入新密碼,並確認後OK
Password changed
Connected.
---------------------------------------------------------------------
ORA-28000: the account is locked:如果三次登陸失敗帳戶會自動被鎖

第一步:使用PL/SQL,登入名為system,資料庫名稱不變,選擇型別的時候把Normal修改為Sysdba;
第二步:選擇myjob,檢視users;
第三步:選擇system,右擊點選“編輯”;
第四步:修改密碼,把“帳戶被鎖住”的勾去掉;
第五步:點選“應用”再點選“關閉”;
第六步:重新登入就可以通過驗證了;
第二種
ALTER USER username ACCOUNT UNLOCK;


第三種


在plsql developer中要是以scott/tiger登入時提示ora-28000 the account is locked。

解決辦法:

新裝完Oracle10g後,用scott/tiger測試,會出現以下錯誤提示:
oracle10g the account is locked
oracle10g the password has expired
原因:預設Oracle10g的scott不能登陸。
解決:
(1)conn sys/sys as sysdba; //以DBA的身份登入
(2)alter user scott account unlock;// 然後解鎖
(3)conn scott/tiger //彈出一個修改密碼的對話方塊,修改一下密碼就可以了

在執行裡面輸入cmd在DOS模式下輸入sqlplus,以system使用者名稱登入,密碼是剛裝oracle時自己填寫的密碼orcl,登入進去以後。

SQL> conn sys/sys as sysdba; (分號是必須的但是我是以system登入的所在這不應該寫conn sys/sys as sysdba應該寫conn system/orcl as sysdba;)
Connected.
SQL> alter user scott account unlock;
User altered.
SQL> commit;
Commit complete.
SQL> conn scott/tiger//請輸入新密碼,並確認後OK
Password changed
Connected.

這時再到plsql developer裡面以scott/tiger登入就可以了。。。。。
-------------------------------------------------------------------

建立新庫注意事項:

我用database configuration assistant 建立了一個數據庫名為testDB, 制定它的globle database name 和SID 都是testDB.

我又已system 登陸oracle 建立了一個anna的使用者:

建立表空間

/*分為四步 */
/*第1步:建立臨時表空間  */
create temporary tablespace user_temp  
tempfile 'D:\oracle\oradata\Oracle9i\user_temp.dbf'
size 50m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  
 
/*第2步:建立資料表空間  */
create tablespace user_data  
logging  
datafile 'D:\oracle\oradata\Oracle9i\user_data.dbf'
size 50m  
autoextend on  
next 50m maxsize 20480m  
extent management local;  
 
/*第3步:建立使用者並指定表空間  */
create user username identified by password  
default tablespace user_data  
temporary tablespace user_temp;  
 
/*第4步:給使用者授予許可權  */
grant connect,resource,dba to username;

ALTER TABLE "U_WEN_BOOK"."GCHILTAB1"
 
    DROP CONSTRAINT "FK_G1"
 
ALTER TABLE "U_WEN_BOOK"."GCHILTAB1"
 
  ADD (CONSTRAINT "FK_G1" FOREIGN KEY()
 
    REFERENCES "U_WEN_BOOK"."CHILTAB"()
 
    ON DELETE CASCADE)
---------------------------------------------------------------

後總是出現ora-12514問題,即TNS 監聽程式不能識別給定的SID。在網上查找了解決方法如下:

到oracle 的安裝目錄下面如C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN中找到listner.ora檔案,

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
      (PROGRAM = extproc)
    )
--------------------------------------------------------
    (SID_DESC =
      (GLOBAL_DBANAME = testDB)
      (ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
      (SID_NAME = testDB)
    )
---------------------------------------------------------
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
  )

在原始的檔案中加入----中的部分,即將你建立的資料庫的SID描述告知給監聽器。儲存檔案。
注意:重新嘗試登陸之前要按順序重新啟動一下testDB服務和TNSListner服務。

sqlplus anna/geh****@testDB

就可以連線入testDB database.

------------------------------------------------------

Oracle插入資料亂碼的問題:

如果你的plsql沒有設定中文字符集的功能,比如我的plsql developer10就沒有,
那可以用設定環境變數的方式解決此問題,在環境變數中新增一個名稱為NLS_LANG值為你oracle字符集
(比如SIMPLIFIED CHINESE_CHINA.ZHS16GBK)的系統變數,重啟plsql developer,重新插入資料,問題即可解決。

-----------------------------------------------------
建立檢視無許可權的問題:

grant create view to scott;

64位oracle啟動時報ORA-01034: ORACLE not available

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
程序 ID: 0
會話 ID: 0 序列號: 0

解決辦法:
1、sqlplus "sys/password as sysdba"
連線成功,提示"已連線到空閒例程"
2、SQL> startup
ORACLE 例程已經啟動。
Total System Global Area  535662592 bytes
Fixed Size                  1375792 bytes
Variable Size             293601744 bytes
Database Buffers          234881024 bytes
Redo Buffers                5804032 bytes
資料庫裝載完畢。
資料庫已啟動