About SQL*Plussql
SQL*Plus is the primary command-line interface to your Oracle database. You use SQL*Plus to start up and shut down the database, set database initialization parameters, create and manage users, create and alter database objects (such as tables and indexes), insert and update data, run SQL queries, and more.数据库
Before you can submit SQL statements and commands, you must connect to the database. With SQL*Plus, you can connect locally or remotely. Connecting locally means connecting to an Oracle database running on the same computer on which you are running SQL*Plus. Connecting remotely means connecting over a network to an Oracle database that is running on a remote computer. Such a database is referred to as a remote database. The SQL*Plus executable on the local computer is provided by a full Oracle Database installation, an Oracle Client installation, or an Instant Client installation.服务器
See Also:网络
Connecting to the Database with SQL*Plusapp
Oracle Database includes the following components:ide
The Oracle Database instance, which is a collection of processes and memoryui
A set of disk files that contain user data and system dataspa
When you connect with SQL*Plus, you are connecting to the Oracle instance. Each instance has an instance ID, also known as a system ID (SID). Because there can be multiple Oracle instances on a host computer, each with its own set of data files, you must identify the instance to which you want to connect. For a local connection, you identify the instance by setting operating system environment variables. For a remote connection, you identify the instance by specifying a network address and a database service name. For both local and remote connections, you must set environment variables to help the operating system find the SQL*Plus executable and to provide the executable with a path to its support files and scripts. To connect to an Oracle instance with SQL*Plus, therefore, you must complete the following steps:操作系统
Step 1: Open a Command Window
Step 2: Set Operating System Environment Variables
根据你的平台,您可能必须在启动SQL * Plus以前设置环境变量,或至少验证设置是否正确
例如,在大多数平台上,必须设置ORACLE_SID和ORACLE_HOME。另外,建议将PATH环境变量设置为包含ORACLE_HOME / bin目录。有些平台可能须要额外的环境变量:
对于全部平台,当在具备不一样Oracle主目录的实例之间切换时,必须更改ORACLE_HOME环境变量。若是多个实例共享同一个Oracle主目录,则在切换实例时必须仅更改ORACLE_SID。
1 setenv ORACLE_SID orcl 2 setenv ORACLE_HOME /u01/app/oracle/product/11.2.0/db_1 3 setenv LD_LIBRARY_PATH $ORACLE_HOME/lib:/usr/lib:/usr/dt/lib:/usr/openwin/lib:/usr/ccs/lib
1 SET ORACLE_SID=orawin2
Example 1-2假定在注册表中设置了ORACLE_HOME和ORACLE_SID,但你但愿覆盖ORACLE_SID的注册表值以链接到其余实例。 在Windows上,您在命令提示符窗口中设置的环境变量值会覆盖注册表中的值。
Step 3: Start SQL*Plus
1 sqlplus /nolog
Step 4: Submit the SQL*Plus CONNECT Statement
the CONNECT
statement is as follows:
CONN[ECT] [logon] [AS {SYSOPER | SYSDBA}]
The syntax of logon
is as follows:
{username | /}[@connect_identifier] [edition={edition_name | DATABASE_DEFAULT}]
下表介绍了CONNECT语句的语法:
/ | 调用链接请求的外部认证。这种类型的认证中不使用数据库密码。 最多见的外部身份验证形式是操做系统身份验证,其中数据库用户经过使用 特定主机用户账户登陆到主机操做系统进行身份验证。外部认证也能够经过 Oracle wallet或network service来进行。 |
AS {SYSOPER | SYSDBA} | 表示数据库用户正在使用SYSOPER或SYSDBA系统特权进行链接。只有 某些预约义的管理用户或已添加到密码文件的用户才可使用这些权限进行链接。 参阅:Administrative Privileges Using Operating System Authentication |
username | 一个有效的数据库用户名。数据库经过将用户名与数据字典匹配并提示输入用户密码 来验证链接请求 |
connect_identifier (1) | 一个Oracle Net链接标识符,用于远程链接。确切的语法取决于Oracle Net配置。 若是省略,SQL * Plus将尝试链接到本地实例。 经常使用链接标识符是网络服务名称。 |
connect_identifier (2) |
做为替代,链接标识符可使用简单链接语法。轻松链接为远程数据库提供开箱即用 的TCP / IP链接,而无需在客户端(本地)计算机上配置Oracle Net Services。 连 接标识符的简单链接语法以下(必须包含括起来的双引号): host[:port][/service_name][:server][/instance_name]
则默认类型的服务器由侦听器选择:共享服务器(若是已配置),不然为专用 服务器 |
|
指定新数据库会话启动的版本。若是指定一个版本,它必须存在,而且您必须具备USE 特权。若是未指定此子句,则会话将使用数据库默认版本 |
参考资料
https://docs.oracle.com/cd/E11882_01/server.112/e25494/dba.htm#ADMIN12472