Oracle启停与sqlplus登陆命令笔记

1. How does one use the SQL*Plus utility?

Start using SQL*Plus by executing the “sqlplus” command-line utility from the $ORACLE_HOME/bin directory. Some of the command line options:

userid/password@db — Connection details
/nolog             — Do not login to Oracle. You will need to do it yourself.
-s or -silent      — start sqlplus in silent mode. Not recommended for beginners!
@myscript          — Start executing script called “myscript.sql”

Logon
has the following syntax:

{username[/password][@connect_identifier | / }

[AS {SYSOPER|SYSDBA}] | /NOLOG 

Logon

username[/password]

Represent the username and password with which you wish to start SQL*Plus and connect to Oracle. If you enter your password on the command-line as part of the SQLPLUS command in the form,

sqlplus username[/password]

it could be viewable by anyone on your system. Some operating systems have monitoring tools that list all executing commands and their arguments.

If you omit username and password, SQL*Plus prompts you for them. If you omit only password, SQL*Plus prompts you for password. When prompting, SQL*Plus does not display password on your terminal screen. In silent mode, username and password prompts are not visible – your username will appear as you type it, but not your password.

@connect_identifier

Consists of an Oracle Net connect identifier. The exact syntax depends upon the Oracle Net communications protocol your Oracle installation uses. For more information, refer to the Oracle Net manual appropriate for your protocol or contact your DBA.

/

Represents a default logon using operating system authentication. You cannot enter a connect_identifer if you use a default logon. In a default logon, SQL*Plus typically attempts to log you in using the username OPS$name, where name is your operating system username. Note that the prefix “OPS$” can be set to any other string of text. For example, you may wish to change the settings in your INIT.ORA parameters file to LOGONname or USERIDname. S

AS {SYSOPER|SYSDBA}

The AS clause allows privileged connections by users who have been granted SYSOPER or SYSDBA system privileges. You can also use either of these privileged connections with / and /NOLOG.

If you use this option, you need to quote the command arguments on many operating systems, for example:

SQLPLUS "/ AS SYSDBA"
SQLPLUS "SYSTEM/your_password AS SYSOPER"

/NOLOG

Establishes no initial connection to Oracle. Before issuing any SQL commands, you must issue a CONNECT command to establish a valid logon. Use /NOLOG when you want to have a SQL*Plus script prompt for the username, password, or database specification. The first line of this script is not assumed to contain a logon.

Look at this example session:

sqlplus /nolog
SQL> CONNECT scott/tiger
SQL> SELECT * FROM tab;
SQL> disconnect
SQL> exit
c:> sqlplus /nolog
sql> CONNECT sys/manager AS sysdba
sql>shutdown immediate
sql> startup
sql> exit
sqlplus / AS sysdba
SQL>startup
SQL>quit

2. 启停Oracle

——————————–Stop Oracle DB:———————————-

su - oracle
sqlplus / AS sysdba
SQL>shutdown immediate

————————-Start Oracle DB:—————————————–

su - oracle
lsnrctl START
export ORACLE_SID=cdlteva3  //cdlteva3 IS the db name , IF there are more than 1 db instance ON the machine
sqlplus / AS sysdba
SQL>startup
SQL>quit

——————————–Check listener status:———————————-

su - oracle
lsnrctl STATUS

——————————Start listener:—————————–

su - oracle
lsnrctl START

——————————Stop listener:—————————–

su - oracle
lsnrctl stop

——————————————————————

3. 查看数据库是否启动

tnsping ora10gcsdl

3 Comments on this Post.

  1. Shuchen Li

    看着你这个日志我就想起我前天和大前天都是早上7点睡的。。。为了oracle的project。。。

  2. admin

    Oracle的project? 现在去甲骨文了? 注意休息啊要。。

  3. Shuchen Li

    没有这么厉害。。。course project而已啦。。。今天刚联系了一个oracle的人 告诉我人家马上要人。。。我得等年底毕业才能工作 算是拒了。。。

Leave a Comment.