官网地址: http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
instantclient-basic-linux.x64-12.2.0.1.0.zip
instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
instantclient-sdk-linux.x64-12.2.0.1.0.zip
(这三个目录可以自定义,但配置环境变量时,需要一致)
[zhaojq@zhaojq ~]$ mkdir -p /home/zhaojq/oracle/lib
[zhaojq@zhaojq ~]$ mkdir -p /home/zhaojq/online1/oracle/sdk
[zhaojq@zhaojq ~]$ mkdir -p /home/zhaojq/online1/oracle/network/admin
[zhaojq@zhaojq ~]$ unzip instantclient-basic-linux.x64-12.2.0.1.0.zip
[zhaojq@zhaojq ~]$ unzip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
这二个文件都解压到当前目录下的同一个目录下面:instantclient_12_2
[zhaojq@zhaojq ~]$ cd instantclient_12_2
[zhaojq@zhaojq instantclient_12_2]$ cp -r * /home/zhaojq/oracle/lib
[zhaojq@zhaojq ~]$ unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip
文件都解压到当前目录下的:instantclient_12_2/sdk
[zhaojq@zhaojq ~]$ cd instantclient_12_2/sdk
[zhaojq@zhaojq ~]$ cp -r * /home/export/base/swyf/zhaojq/online1/oracle/sdk
[zhaojq@zhaojq ~]$ vi /etc/profile
加入
export ORACLE_HOME=/home/zhaojq/oracle
export LD_LIBRARY_PATH=/home/zhaojq/oracle/lib
保存并退出。
[zhaojq@zhaojq ~]$ source /etc/profile
[zhaojq@zhaojq ~]$ echo $ORACLE_HOME
/home/zhaojq/oracle
在/home/zhaojq/oracle/network/admin目录下创建3个文件
[zhaojq@zhaojq admin]$ ls
listener.ora sqlnet.ora tnsnames.ora
编辑三个文件
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /home/zhaojq/oracle)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.3)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.4)(PORT = 1521))
)
)
直接使用/u01/app/oracle/product/12.1.0/db_1/network/admin/samples下的默认sqlnet.ora
不同的数据库名称,需要修改第一行和第八行!
DPSS3 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.3)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.4)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dpss3)
(FAILOVER_MODE=
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
[zhaojq@zhaojq ~]$ cd /home/zhaojq/oracle/lib
[zhaojq@zhaojq lib]$ ./sqlplus 'sys/"password"'@dpss3 as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Mon Jun 19 15:56:28 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL>
注:当Oracle数据库用户的密码含特殊字符如 @ 时,直接使用正常的密码输入会导致登陆失败。(ORA-12532: TNS:invalid argument)
采用如下格式登录: ‘用户名/”密码”’@数据库名
SQL> select name from v$database;
NAME
---------
dpss3
SQL> create user c##test identified by test;
User created.
SQL> alter user c##test identified by test123;
User altered.
SQL> drop user c##test;
User dropped.
若用户拥有对象,则不能直接删除,否则将返回一个错误值。指定关键字cascade,可删除用户所有的对象,然后再删除用户。
临时用户,特指不需要建表的用户,通常只赋予他们connect role.
connect是使用oracle简单权限,这种权限只对其他用户的表有访问权限,包括select/insert/update和delete等。
拥有connect role 的用户还能够创建表、视图、序列(sequence)、簇(cluster)、同义词(synonym)、回话(session)和其他 数据的链(link)
更可靠和正式的数据库用户可以授予resource role。
resource提供给用户另外的权限以创建他们自己的表、序列、过程(procedure)、触发器(trigger)、索引(index)和簇(cluster)。
dba role拥有所有的系统权限
包括无限制的空间限额和给其他用户授予各种权限的能力。system由dba用户拥有
SQL> grant connect, resource to c##test;
Grant succeeded.
SQL> revoke connect, resource from c##test;
Revoke succeeded.
[zhaojq@zhaojq lib]$ ./sqlplus c##test/test@dpss3
SQL*Plus: Release 12.2.0.1.0 Production on Fri Jul 28 16:47:20 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL>