怎样使用sqlplus连接oracle11g数据库
今至电子科技有限公司
2024-08-23 广告
2024-08-23 广告
数据库备份是确保数据安全与业务连续性的关键环节。我们上海今至电子科技有限公司高度重视数据保护,定期执行全面的数据库备份策略。这包括使用先进工具和技术,对关键业务数据进行自动化备份,并存储在安全可靠的外部存储介质或云端。通过定期验证备份的完整...
点击进入详情页
本回答由今至电子科技有限公司提供
展开全部
在E:\uplooking\work\Oracle\instantclient_11_2(我的oracle客户端安装目录)目录下,新建两个文件,名称分别为 sqlnet.ora,tnsnames.ora。这两个文件提供了客户端服务名到指定的oracle服务器提供的数据库服务名的映射。
sqlnet.ora内容如下:
NAMES.DIRECTORY_PATH = (TNSNAMES,EZCONNECT)
tnsnames.ora内容如下:
xndata =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.111)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcldb)
)
)
其中,
客户端服务名可以任意设置,
服务器IP地址就是提供oracle服务的机器IP,
服务器端侦听器提供的服务名是根据服务器端的设置填写。
【注意】客户端服务名必须顶格写,前面不能有任何空格,否则会出错。
然后,为系统添加环境变量TNS_ADMIN,其值为oracle客户端安装目录,本例中就是TNS_ADMIN:E:\uplooking\work\Oracle\instantclient_11_2
注:使环境变量不用重启电脑也可以生效方法
cmd命令行下:set TNS_ADMIN=E:\uplooking\work\Oracle\instantclient_11_2 设置环境变量
重新打开一个cmd命令行:echo %TNS_ADMIN% --检查是否输出新的环境变量值
sqlnet.ora内容如下:
NAMES.DIRECTORY_PATH = (TNSNAMES,EZCONNECT)
tnsnames.ora内容如下:
xndata =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.111)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcldb)
)
)
其中,
客户端服务名可以任意设置,
服务器IP地址就是提供oracle服务的机器IP,
服务器端侦听器提供的服务名是根据服务器端的设置填写。
【注意】客户端服务名必须顶格写,前面不能有任何空格,否则会出错。
然后,为系统添加环境变量TNS_ADMIN,其值为oracle客户端安装目录,本例中就是TNS_ADMIN:E:\uplooking\work\Oracle\instantclient_11_2
注:使环境变量不用重启电脑也可以生效方法
cmd命令行下:set TNS_ADMIN=E:\uplooking\work\Oracle\instantclient_11_2 设置环境变量
重新打开一个cmd命令行:echo %TNS_ADMIN% --检查是否输出新的环境变量值
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
oracle认证2种方式:
1本机认证, windows(administrator), unix(root) 用户的前提下,
你可以直接, sqlplus /as systdba 就可以直接连了
2用户名密码验证
确保你的tnsnames.ora的配置是正确的, 配置的示例alias会被用来使用连接数据库
sqlplus username/password@db_alias_name 这样就可以连接并使用了.
1本机认证, windows(administrator), unix(root) 用户的前提下,
你可以直接, sqlplus /as systdba 就可以直接连了
2用户名密码验证
确保你的tnsnames.ora的配置是正确的, 配置的示例alias会被用来使用连接数据库
sqlplus username/password@db_alias_name 这样就可以连接并使用了.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看 help啊,最基本的操作命令 help都有。
1、切换到oracle用户
[root@oracle ~]# su - oracle
2、查看帮助
[oracle@oracle ~]$ sqlplus --help
SQL*Plus: Release 11.2.0.1.0 Production
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus statements.
Usage 1: sqlplus -H | -V
-H Displays the SQL*Plus version and the
usage help.
-V Displays the SQL*Plus version.
Usage 2: sqlplus [ [<option>] [{logon | /nolog}] [<start>] ]
<option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S]
-C <version> Sets the compatibility of affected commands to the
version specified by <version>. The version has
the form "x.y[.z]". For example, -C 10.2.0
-L Attempts to log on just once, instead of
reprompting on error.
-M "<options>" Sets automatic HTML markup of output. The options
have the form:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
[ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
-R <level> Sets restricted mode to disable SQL*Plus commands
that interact with the file system. The level can
be 1, 2 or 3. The most restrictive is -R 3 which
disables all user commands interacting with the
file system.
-S Sets silent mode which suppresses the display of
the SQL*Plus banner, prompts, and echoing of
commands.
<logon> is: {<username>[/<password>][@<connect_identifier>] | / }
[AS {SYSDBA | SYSOPER | SYSASM}] [EDITION=value]
Specifies the database account username, password and connect
identifier for the database connection. Without a connect
identifier, SQL*Plus connects to the default database.
The AS SYSDBA, AS SYSOPER and AS SYSASM options are database
administration privileges.
<connect_identifier> can be in the form of Net Service Name
or Easy Connect.
@[<net_service_name> | [//]Host[:Port]/<service_name>]
<net_service_name> is a simple name for a service that resolves
to a connect descriptor.
Example: Connect to database using Net Service Name and the
database net service name is ORCL.
sqlplus myusername/mypassword@ORCL
Host specifies the host name or IP address of the database
server computer.
Port specifies the listening port on the database server.
<service_name> specifies the service name of the database you
want to access.
Example: Connect to database using Easy Connect and the
Service name is ORCL.
sqlplus myusername/mypassword@Host/ORCL
The /NOLOG option starts SQL*Plus without connecting to a
database.
The EDITION specifies the value for Session Edition.
<start> is: @<URL>|<filename>[.<ext>] [<parameter> ...]
Runs the specified SQL*Plus script from a web server (URL) or the
local file system (filename.ext) with specified parameters that
will be assigned to substitution variables in the script.
When SQL*Plus starts, and after CONNECT commands, the site profile
(e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
(e.g. login.sql in the working directory) are run. The files may
contain SQL*Plus commands.
Refer to the SQL*Plus User's Guide and Reference for more information.
3、简单的示范:
[oracle@oracle ~]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Tue Sep 13 16:27:54 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: user1
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from dual;
D
-
X
SQL>
1、切换到oracle用户
[root@oracle ~]# su - oracle
2、查看帮助
[oracle@oracle ~]$ sqlplus --help
SQL*Plus: Release 11.2.0.1.0 Production
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Use SQL*Plus to execute SQL, PL/SQL and SQL*Plus statements.
Usage 1: sqlplus -H | -V
-H Displays the SQL*Plus version and the
usage help.
-V Displays the SQL*Plus version.
Usage 2: sqlplus [ [<option>] [{logon | /nolog}] [<start>] ]
<option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S]
-C <version> Sets the compatibility of affected commands to the
version specified by <version>. The version has
the form "x.y[.z]". For example, -C 10.2.0
-L Attempts to log on just once, instead of
reprompting on error.
-M "<options>" Sets automatic HTML markup of output. The options
have the form:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
[ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
-R <level> Sets restricted mode to disable SQL*Plus commands
that interact with the file system. The level can
be 1, 2 or 3. The most restrictive is -R 3 which
disables all user commands interacting with the
file system.
-S Sets silent mode which suppresses the display of
the SQL*Plus banner, prompts, and echoing of
commands.
<logon> is: {<username>[/<password>][@<connect_identifier>] | / }
[AS {SYSDBA | SYSOPER | SYSASM}] [EDITION=value]
Specifies the database account username, password and connect
identifier for the database connection. Without a connect
identifier, SQL*Plus connects to the default database.
The AS SYSDBA, AS SYSOPER and AS SYSASM options are database
administration privileges.
<connect_identifier> can be in the form of Net Service Name
or Easy Connect.
@[<net_service_name> | [//]Host[:Port]/<service_name>]
<net_service_name> is a simple name for a service that resolves
to a connect descriptor.
Example: Connect to database using Net Service Name and the
database net service name is ORCL.
sqlplus myusername/mypassword@ORCL
Host specifies the host name or IP address of the database
server computer.
Port specifies the listening port on the database server.
<service_name> specifies the service name of the database you
want to access.
Example: Connect to database using Easy Connect and the
Service name is ORCL.
sqlplus myusername/mypassword@Host/ORCL
The /NOLOG option starts SQL*Plus without connecting to a
database.
The EDITION specifies the value for Session Edition.
<start> is: @<URL>|<filename>[.<ext>] [<parameter> ...]
Runs the specified SQL*Plus script from a web server (URL) or the
local file system (filename.ext) with specified parameters that
will be assigned to substitution variables in the script.
When SQL*Plus starts, and after CONNECT commands, the site profile
(e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
(e.g. login.sql in the working directory) are run. The files may
contain SQL*Plus commands.
Refer to the SQL*Plus User's Guide and Reference for more information.
3、简单的示范:
[oracle@oracle ~]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Tue Sep 13 16:27:54 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: user1
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from dual;
D
-
X
SQL>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
打开本地的Oracle数据库:
在CMD窗口输入:sqlplus 回车后提示输入用户名和密码即可;
打开远程的Oracle数据库:
在CMD窗口中输入:sqlplus 用户名/密码@TNS
TNS:配置好的远程数据库服务实例名
在CMD窗口输入:sqlplus 回车后提示输入用户名和密码即可;
打开远程的Oracle数据库:
在CMD窗口中输入:sqlplus 用户名/密码@TNS
TNS:配置好的远程数据库服务实例名
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询