1. 程式人生 > >PLSQL Developer 12.0.7連線Oracle12c資料庫

PLSQL Developer 12.0.7連線Oracle12c資料庫

Windows下使用PL/SQL Developer 12.0.7連線Oracle12c資料庫

1.下載安裝PL/SQL Developer

下載PL/SQL Developer - Registered Download,這裡選擇當前最新版12.0.7x64位plsqldev1207x64.msi
雙擊plsqldev1207x64.msi進行安裝,註冊碼參見PLSQL Developer 12.0.7 64位 註冊碼,設定如下:

product code: 4vkjwhfeh3ufnqnmpr9brvcuyujrx3n3le
serial Number226959
password: xs374ca

2.下載Oracle Instant Client

PL/SQL Developer使用配合Oracle Instant Client

下載Oracle Instant Client,這裡選擇Instant Client for Microsoft Windows (x64),版本Version 12.2.0.1.0,選擇instantclient-basic-windows.x64-12.2.0.1.0.zip

Version 12.2.0.1.0的Oracle資料庫安裝可參見Linux命令列安裝Oracle12c

將下載的instantclient-basic-windows.x64-12.2.0.1.0.zip解壓到和PL/SQL Developer安裝的同級目錄下(也可以是別的目錄,看個人需要)
放在同級目錄下

3.配置PL/SQL Developer首選項

①開啟PLSQL Developer,登入介面如下,點選Cancel取消按鈕
PL/SQL Developer 12.0.7登入介面

②點選選單欄右上角按鈕,或選擇Configure-Preferences
點選或選擇Configure-Preferences

③開啟的Preferences視窗中,配置Oracle Home路徑為Oracle Instant Client解壓安裝路徑
下次啟動PL/SQL生效
OCI library為Oracle Instant Client解壓安裝路徑下的oci.dll檔案
配置OracleHome
點選Apply-點選OK,使配置生效

④關閉PLSQL Developer,重新開啟,多出了Connect as選項
配置了Oracle Instant Client後的顯示

4.配置Oracle Instant Client

PLSQL Developer的登入介面沒有資料庫的初始化內容

在Oracle Instant Client解壓安裝目錄下\NETWORK\ADMIN新建tnsnames.ora檔案,instantclient_12_2下沒有NETWORK\ADMIN目錄,也要新建
配置tnsnames.ora

tnsnames.ora內容如下:

cdb1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Oracle服務IP)(PORT = 1521))
    (CONNECT_DATA =
      (SERVICE_NAME = cdb1)
    )
  )

Oracle服務IP替換為Oracle的IP地址,配置完成後,關閉PLSQL Developer,重新啟動

5.PL/SQL Developer登入Oracle

啟動PLSQL Developer後出現的登入介面如下
配置完成tnsnames.ora後顯示

這時如果不知道用哪個使用者名稱登入,可以使用命令列語句檢視oracle所有的使用者,以及該使用者的狀態
select username,account_status from dba_users;

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon May 28 15:28:45 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select username,account_status from dba_users;

USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
SYS
OPEN

SYSTEM
OPEN

XS$NULL
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
OJVMSYS
EXPIRED & LOCKED

LBACSYS
EXPIRED & LOCKED

OUTLN
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
SYS$UMF
EXPIRED & LOCKED

DBSNMP
EXPIRED & LOCKED

APPQOSSYS
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
DBSFWUSER
EXPIRED & LOCKED

GGSYS
EXPIRED & LOCKED

ANONYMOUS
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
CTXSYS
EXPIRED & LOCKED

SI_INFORMTN_SCHEMA
EXPIRED & LOCKED

DVSYS
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
DVF
EXPIRED & LOCKED

GSMADMIN_INTERNAL
EXPIRED & LOCKED

ORDPLUGINS
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
MDSYS
EXPIRED & LOCKED

OLAPSYS
EXPIRED & LOCKED

ORDDATA
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
XDB
EXPIRED & LOCKED

WMSYS
EXPIRED & LOCKED

ORDSYS
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
GSMCATUSER
EXPIRED & LOCKED

MDDATA
EXPIRED & LOCKED

SYSBACKUP
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
REMOTE_SCHEDULER_AGENT
EXPIRED & LOCKED

GSMUSER
EXPIRED & LOCKED

SYSRAC
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
AUDSYS
EXPIRED & LOCKED

DIP
EXPIRED & LOCKED

SYSKM
EXPIRED & LOCKED


USERNAME
--------------------------------------------------------------------------------
ACCOUNT_STATUS
--------------------------------
ORACLE_OCM
EXPIRED & LOCKED

SYSDG
EXPIRED & LOCKED

SPATIAL_CSW_ADMIN_USR
EXPIRED & LOCKED


36 rows selected.

SQL> quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

使用者狀態為OPEN的使用者為SYSSYSTEM,其中SYS為超級管理員使用者
使用者SYSSYSTEM的密碼為資料庫建立時的密碼

忘記密碼可進行修改

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon May 28 15:28:45 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> alter user you_username identified by you_password;

alter user system identified by OraPasswd1;

system使用者輸入使用者名稱和密碼,資料庫為cdb1,Normal方式連線
system使用者登入
sys使用者輸入使用者名稱和密碼,資料庫為cdb1,SYSDBA或SYSOPER方式連線
sys使用者登入

6.PL/SQL Developer顯示SQL行號

點選選單欄右上角按鈕,或選擇Configure-Preferences,左側找到SQL Window,右側找到Show gutter(line numbers)並勾選,Apply然後點選OK
PLSQLDeveloper顯示SQL行號

7.PL/SQL Developer中文亂碼處理

PLSQL執行SQL中文亂碼

①檢視資料庫字符集
select userenv('language') from dual;
檢視資料庫字符集
字符集為AMERICAN_AMERICA.AL32UTF8

②檢視本地字符集
select * from V$NLS_PARAMETERS;
檢視本地字符集
發現第一行和第九行是相對應的,AMERICAN_AMERICA.AL32UTF8

③新建系統環境變數NLS_LANG
變數值和資料庫的字符集相同,若已存在系統變數NLS_LANG,則更新變數值
新建系統環境變數
不新建到系統變數裡,新建到上面的使用者變數裡也能正常使用。

④重新開啟PL/SQL Developer
亂碼問題已解決

8.PL/SQL Developer刪除登入記錄

最近登入過的使用者記錄會在開啟PL/SQL Developer中顯示
最近登入歷史記錄
開啟Preferences視窗,選擇Logon History,刪除不常使用到的使用者
刪除PLSQL登入歷史記錄

本文參考:
PL/SQL Developer連線到Oracle 12c
PLSQL Developer 12.0.7 64位 註冊碼
plsql中文亂碼問題(顯示問號)