Oracle Enterprise Manager Administrator's Guide | ![]() Library |
![]() Product |
![]() Contents |
![]() Index |
This appendix describes the Server Manager DBA commands available in line mode. These commands can also be used in a SQL Worksheet, although some of these commands behave differently when used in a worksheet.
DBA Commands
The DBA commands described in this appendix are:
STARTUP OPEN 'V7'
where:
scriptname
Do not use the @ command alone within a script unless you specify the full path name of the script.
ARCHIVE LOG
Purpose
Start or stop automatic archiving of online redo log files, manually (explicitly) archive specified redo log files, or display information about redo log files.
This command applies only to the current instance. To specify archiving for a different instance or for all instances in a Parallel Server, use the SQL command ALTER SYSTEM. Prerequisites
You must be connected to an open Oracle database as INTERNAL, SYSOPER, or SYSDBA. Syntax
ARCHIVE LOG command ::=
Requests a display that shows the range of redo log files to be archived, the current log file group's sequence number, and the current archive destination (specified by either the optional command text or by the initialization parameter LOG_ARCHIVE_DEST).Database log mode Archive Mode
Automatic archival Enabled
Archive destination DISK9:ARCH
Oldest online log sequence 30
Next log sequence to archive 33
Current log sequence 33
Because the log sequence number of the current log group and the next log group to archive are the same, automatic archival has archived all log groups up to the current one. Oldest online log sequence 30
Next log sequence to archive 30
Current log sequence 33
If you are using NOARCHIVELOG mode, the "next log sequence to archive" line is suppressed.
Disables automatic archival. If the instance is still in ARCHIVELOG mode and all redo log file groups fill, database operation is suspended until a redo log file is archived (for example, until you enter the command ARCHIVE LOG NEXT or ARCHIVE LOG ALL).
Enables automatic archiving. Starts the background process ARCH, which performs automatic archiving as required. If ARCH is started and a filename is supplied, the filename becomes the new default archive destination.
Manually archives the next online redo log file group that has been filled but not yet archived.
Manually archives all filled, but not yet archived, online log file groups.
Causes archival of the online redo log file group with log sequence number n. You can specify any redo log file group that is still online. An error occurs if the log file cannot be found online or the sequence number is not valid. This option can be used to re-archive a log file group.
Specifies the destination device or directory in an operating system. Specification of archive destination devices is installation-specific; see your platform-specific Oracle documentation for examples of specifying archive destinations. On many operating systems, multiple log files can be spooled to the same tape. Usage Notes
If an online redo log file group fills and none are available for reuse, database operation is suspended. The condition can be resolved by archiving a log file group.
ARCHIVE LOG STARTARCHIVE LOG STOP
Stops automatic archiving. ARCHIVE LOG 1001 'DISK9:[TEMPARCH]TEMP'
Archives the log file group with the sequence number 1001 to the destination specified. 'TEMP' specifies the prefix of the filename on the destination device; the remainder of the filename is dependent on the initialization parameter LOG_ARCHIVE_FORMAT, which specifies the filename format for archived redo log files. CONNECT
Purpose
Connect to a database using the specified username. Prerequisites
Only valid username/password combinations can successfully connect. The AS clause allows users to connect to an instance with a default schema of SYS for database administration. Users connecting as SYSOPER or SYSDBA must have the necessary privileges to access the SYS schema. Syntax
CONNECT command ::=
Any valid Oracle username for the current database. It can be a null string. If neither username nor INTERNAL is specified, you are prompted for a username and password.
The password corresponding to the specified username. Password can be a null string.
A valid specification for an instance/database combination. If an instance is specified, it becomes the current instance for the duration of the connection. It does not become the default instance for subsequent connections.
The AS clause allows privileged connections by users who have been granted SYSOPER or SYSDBA system privileges, if using a password file, or their operating system equivalents, if using OS authentication.
Uses operating system authentication.
Connects as username SYS via keyword INTERNAL. Should be used rarely and only by the DBA for certain maintenance purposes; requires operating system privileges. CONNECT INTERNAL is supported for backwards compatibility only. Line Mode Behavior
If you omit the password, you are prompted for one. If you omit both the username and password, you are prompted for both. SQL Worksheet Behavior
If you omit the username argument, the Connect dialog box displays. Usage Notes
If only the Oracle username is specified, the password is requested using the prompt "Password:". The entered password is not echoed.
To connect to Oracle as a privileged user over a local or a secure connection, you must satisfy either of the following sets of conditions:
CONNECTTo connect to an instance on the current node as username SCOTT with password TIGER, enter:
CONNECT scott/tigerTo use a password file to connect to an instance on the current node as a privileged user named SCOTT with password TIGER, enter:
CONNECT scott/tiger AS SYSDBANote that your default schema is now SYS, not SCOTT.
To perform the same connection using OS authentication, enter:
CONNECT / AS SYSDBATo connect to an instance on a different node as username SCOTT with password TIGER, enter:
CONNECT scott/tiger@instance-path
where:
name
DESCRIBE empServer Manager describes the table or view if a table or view with the name EMP exists. If no table or view with that name exists in the user's schema, Server Manager will search for a PL/SQL function, procedure, or package with that name and describe it.
The shorthand DESC is now equivalent to the command DESCRIBE. This means that DESC has been added to the list of Server Manager reserved words. If you have a database object named DESC, you need to place quotes around the name to show that it is an object name. For example:
INSERT INTO 'DESC' VALUES('onetwothree', 123); )Note:
Example
DESCRIBE scott.addempproduces output similar to the following example:
PROCEDURE SCOTT.ADDEMP (EMPNO INTEGER, ENAME VARCHAR2, SAL NUMBER(9,2))The use of the object type is no longer required. If you do not specify an object type, Server Manager attempts to determine the object type. For the statement
DESCRIBE empServer Manager describes the table or view if a table or view with the name EMP exists.
If no table or view with that name exists in the user's schema, Server Manager searches for a PL/SQL function, procedure, or package with that name and describes it. For the statement
DESCRIBE payroll.empServer Manager looks for a table or view in schema PAYROLL with the name EMP.
If there is no PAYROLL schema or no EMP table/view in the PAYROLL schema, Server Manager will search the current schema for a package PAYROLL containing a function or procedure EMP.
If both a table EMP in schema PAYROLL and a package PAYROLL with function/procedure EMP in the current schema exist, the statement
DESCRIBE FUNCTION payroll.empThis allows you to specify the type of the object you want to describe.
Server Manager now has the capability to describe both functions and procedures contained in packages. Previously only functions and procedures not contained in packages could be described.
Note:
Example
BEGIN
[PL/SQL BLOCK]
END;You can reference any command line mode bind variables in PL/SQL statements by preceding the variable name with a colon. The example below illustrates the use of bind variables with the VARIABLE, EXECUTE, and PRINT commands.
Example
EXECUTE :balance := get_balance(34056)
PRINT balance
BALANCE
----------
4678.24
SQL Worksheet Behavior
Example
where:
variable
If no variable name is specified all currently defined variables are printed.
Examples
BALANCE
----------
4687.24
SET CHARWIDTH 10
PRINT ename
ENAME
----------
SCOTT
UNTIL clause ::=
PARALLEL clause ::=
where:
DATABASE
USING BACKUP CONTROL FILE
TABLESPACE tablespace
DATAFILE filename
UNTIL CANCEL
UNTIL CHANGE integer
UNTIL TIME date
'YYYY-MM-DD:HH24:MI:SS'.PARALLEL
DEGREE DEFAULT indicates that twice the number of datafiles being recovered is the number of recovery processes to use.
INSTANCES specifies the number of instances to use for parallel recovery. The number of recovery processes specified with DEGREE is used on each instance, thus the total number of recovery processes is the integer specified with DEGREE multiplied by the integer specified with INSTANCES. INSTANCES is only pertinent for the Oracle Parallel Server.
INSTANCES DEFAULT or not including the INSTANCES keyword causes has operating system-specific consequences. Consult your Oracle operating system documentation for a description of the default behavior of the INSTANCES DEFAULT specification.
NOPARALLEL
The PARALLEL keyword overrides the RECOVERY_PARALLELISM initialization parameter. The number specified with the PARALLEL keyword is the number of recovery processes used to apply redo entries to datafiles.
To perform media recovery on a tablespace, the database must be mounted and open, and the tablespace must be offline.
To perform media recovery on a datafile, the database can remain open and mounted with the damaged datafiles offline (unless the file is part of the SYSTEM tablespace).
Before using the RECOVER command you must have restored good copies of the damaged datafile(s) from a previous backup. Be sure you can access all archived and online redo log files dating back to when that backup was made.
When another log file is required during recovery, a prompt suggests the names of files that are needed. The name is derived from the values specified in the initialization parameters LOG_ARCHIVE_DEST and LOG_ARCHIVE_FORMAT. You should restore copies of the archived redo log files needed for recovery to the destination specified in LOG_ARCHIVE_DEST, if necessary. You can override the initialization parameters by setting the LOGSOURCE variable.
During recovery you can accept the suggested log name by hitting return, cancel recovery by entering CANCEL instead of a log name, or enter AUTO for automatic file selection without further prompting.
If you have enabled autorecovery (that is, SET AUTORECOVERY ON), recovery proceeds without prompting you with filenames. Status messages are displayed when each log file is applied.
When normal media recovery is done, a completion status is returned.
For more information on recovery and the RECOVER command, see the Oracle7 Server Administrator's Guide.
Examples
RECOVER DATABASE UNTIL TIME 30-AUG-90:04:32:00
RECOVER TABLESPACE ts_one, ts_two
RECOVER DATAFILE 'data1.db'
REM must be the first non-blank character string in the line.
Examples
REM This command file is used to create a
REM database. Edit it to fill in file names
REM and sizes, and invoke it from line mode.
REM
REM
CREATE DATABASE dbname ....
/* This is a SQL Comment */ ...
...
;REMARKs are recognized by SQL*Plus, as well as by line mode. They are used to put Comments between SQL statements, while SQL Comments (/*...*/) are used to place comments within statements.
where:
APPINFO
Application registration allows DBAs to see what software is currently running to better monitor resource utilization for database tuning. When APPINFO is turned on, application registration proceeds normally. If a SQL script is not being run, the default registration text string is "Oracle SQL Worksheet." Optionally, you can create a customized registration text string. If a script is being run through Server manager, the script name is used as the registration text string.
Text String Registers as:
SET APPINFO abc abc
SET APPINFO abc def abc
SET APPINFO "abc def" abc def
SET APPINFO 'abc def' abc def
SET APPINFO "abc def Error
SET APPINFO 'abc def ErrorAUTO- RECOVERY
OFF, the default option, requires that you enter the filenames manually or accept the suggested default filename given.
CHARWIDTH integer
COMPATIBILITY
CHAR Columns: When creating tables in Version 6 compatibility mode, CHAR columns are variable length. In Oracle7, such column definitions are fixed length.
Integrity Constraints: In Version 6 compatibility mode, the Version 6 syntax is still recognized, and the Oracle7 syntax is disabled. For V6 mode, table constraints on CREATE TABLE statements are specified with V6 syntax:
CREATE TABLE {UNIQUE | PRIMARY KEY} CONSTRAINT ....
and specified constraints are disabled by default. For V7 mode, table constraints are specified with Oracle7 syntax:
CREATE TABLE CONSTRAINT .... {UNIQUE | PRIMARY KEY}
and they are enabled.
Rollback Segment Parameters: Version 6 compatibility mode allows PCTINCREASE and MAXEXTENTS to be specified for rollback segments, as well as for other segments. Although the specifications are ignored, the syntax is allowed. (Use of these parameters is not recommended. They exist only for backward compatibility.)
Bind Variables: Bind variables of type VARCHAR2 are given type CHAR in Version 6 compatibility mode.
DATEWIDTH integer
ECHO
FETCHROWS integer
In a SQL Worksheet the default is ECHO ON.
INSTANCE instance-path
Any commands preceding the first use of SET INSTANCE communicate with the default instance.
To reset the instance to the default value for your operating system, you can either enter SET INSTANCE with no instance-name or SET INSTANCE LOCAL. See your operating system-specific Oracle documentation for a description of how to set the initial default instance.
This command may only be issued when SQL*Net is running. You can use any valid SQL*Net connect string as the specified instance path. See your operating system-specific Oracle documentation for a complete description of how your operating system specifies SQL*Net connect strings. The maximum length of the instance path is 64 characters.
LOGSOURCE pathname
LONGWIDTH integer
MAXDATA integer
NUMWIDTH integer
RETRIES
SERVEROUTPUT
ON enables debugging output from stored procedures that use DBMS_OUTPUT PUT and PUT_LINE commands. OFF disables output.
Specifying ON indicates that if a command file is running and an error occurs, execution should terminate. OFF disables STOPONERROR.
ON, the default, enables terminal output for SQL commands. OFF disables terminal output. Useful for preventing output to terminal when spooling output to files. Note that nothing appears on the terminal until SET TERMOUT ON is used.
ON displays parse, execute, and fetch times (CPU and elapsed) for each SQL statement executed. OFF, the default, does not display timing information.
SET INSTANCE D:DEV-PROD SET TIMING ON
SET LONGWIDTH 132
SET NUMWIDTH 20
SET CHARWIDTH 5
Either of the following commands can be used to revert to the initial default host:SET INSTANCE
SET INSTANCE LOCAL
SHOW
Purpose
Show settings currently in effect. Prerequisites
None. Syntax
SHOW command ::=
Shows all settings except for ERRORS, PARAMETERS, and SGA.
Shows the current status (ON/OFF) and the application registration text.
Shows the column display width for CHAR data.
Shows the sessions compatibility mode: V6, V7, or NATIVE.
Shows the column display width for DATE data.
Shows whether or not commands from command files are echoed.
Shows the errors generated from the last compilation of a procedure, package, or function, if any. This option displays the line number, column number, and the error message generated. Use the SHOW ERRORS command if line mode error 72 or 73 is returned after compiling a package.
Shows the numerical limit set for the number of rows returned by a query.
Shows the connect string for the default instance. SHOW INSTANCE returns the value LOCAL if you have not used SET INSTANCE or if you have used the LOCAL option of the SET INSTANCE command.
Shows the current setting for archive log location. Displays DEFAULT if the default setting is in effect, as specified by the LOG_ARCHIVE_DEST initialization parameter.
Shows the column display width for LONG data.
Shows the maximum data size.
Shows column display width for NUMBER data.
Displays the current values for one or more initialization parameters. You can use a string after the command to see a subset of parameters whose names include that string. For example, if you enter: SHOW PARAMETERS COUNT
you would see: NAME TYPE VALUE
------------------- ------- -----
db_file_multiblock_read_count integer 12
spin_count integer 0
The SHOW PARAMETERS command, without any string following the command, displays all initialization parameters.
Displays the number of retries that will be attempted when restarting an instance in parallel mode. (See RETRY on page B-34 . It is an option in "STARTUP". )
SERVEROUTPUT
Displays ON if output from stored procedures and functions is enabled. Otherwise, displays OFF. SERVEROUTPUT is reset to OFF if you issue a CONNECT command.
Displays information about the current instance's System Global Area.
If spooling is enabled, displays the name of the output spool file. Otherwise, displays OFF.
Displays whether or not errors encountered during execution of command files should stop execution of the file.
Shows if output to the terminal is enabled.
Shows whether or not the parse, execute, and fetch times (CPU and elapsed) for each SQL statement executed are shown. Usage Notes
SHOW with no arguments is the same as SHOW ALL.
SHOW TIMING Timing OFF
SHOW ALL
returns a display like: Instance local
Spool OFF
Timing OFF
Termout ON
Echo OFF
Stoponerror OFF
Autorecovery OFF
Logsource <default>
Maxdata 20480
Numwidth 10
Charwidth 80
Longwidth 80
Datewidth 9
Labwidth 32
Compatibility NATIVE
Retries infinite
Server Output OFF
SHOW SGA
returns a display like: Total Shared Global Area 4612820 bytes
Fixed Size 36376 bytes
Variable Size 4445372 bytes
Database Buffers 122880 bytes
Redo Buffers 8192 bytes
SHOW ERRORS PACKAGE BODY name
returns a display like: ERRORS FOR PACKAGE BODY name:
LINE/COL ERRORS
---------------------------------------------------------------
...
SHUTDOWN
Purpose
Shut down a currently running Oracle instance, optionally closing and dismounting a database. Prerequisites
You must be connected to a database as INTERNAL, SYSOPER, or SYSDBA. You cannot be connected via a multi-threaded server. Syntax
SHUTDOWN command ::=
Proceeds with the fastest possible shutdown. Does not wait for calls to complete or users to disconnect. Does not close or dismount the database, but does shut down the instance. Requires instance recovery on next startup. You must use this option if a background process terminates abnormally.
Does not wait for current calls to complete, prohibits further connects, and closes and dismounts the database. Finally, shuts down the instance. Does not wait for connected users to disconnect. Does not require instance recovery on next startup.
Waits for currently connected users to disconnect from the database, prohibits further connects, and closes and dismounts the database. Finally, shuts down the instance. Does not require instance recovery on next startup. NORMAL is the
default option.
In Server Manager, you can have several separate connections open at any time in multiple windows. If you have any connections open, remember to close them before performing a shutdown in normal mode. Otherwise, the shutdown will not complete.
SHUTDOWN Database closed.
Database dismounted.
Oracle instance shut down.
SPOOL
Purpose
Enable or disable spooling of output to a specified file. Prerequisites
None. Syntax
SPOOL command ::=
Any valid name for a spool file. If not specified, the file type or file extension is LOG. If a file by the specified name exists, an error is generated.
Closes the previously opened spool file. Usage Notes
If you do not specify a file, Server Manager prompts you for a filename.
When long lines of text (usually from a table query) are written to a spool file or to a terminal, newline codes are inserted in the text if the lines exceed the maximum line length for the platform.
To create a file named NOV2.LOG, enter: SPOOL NOV2
STARTUP
Purpose
Start an Oracle instance with several options, including mounting and opening a database. Prerequisites
You must be connected to a database as INTERNAL, SYSOPER, or SYSDBA. You cannot be connected via a multi-threaded server. Syntax
STARTUP command ::=
Shuts down the current Oracle instance (if it is running) with SHUTDOWN mode ABORT, before restarting it. If the current instance is running and FORCE is not specified, an error results. FORCE is useful while debugging and under abnormal circumstances. It should not normally be used.
Only allows Oracle users with the RESTRICTED SESSION system privilege to connect to the database. Later, you can use the ALTER SYSTEM command to disable the restricted session feature.
Causes the specified parameter file to be used while starting up the instance.
Mounts a database but does not open it.
Mounts and opens the specified database.
Causes the database not to be mounted upon instance startup. Cannot be used with SHARED, EXCLUSIVE, PARALLEL, MOUNT, or OPEN.
Specifies that media recovery should be performed, if necessary, before starting the instance. STARTUP RECOVER has the same effect as issuing the RECOVER DATABASE command and starting an instance. Only complete recovery is possible with the RECOVER option.
If recovery fails using the RECOVER option, the database remains mounted and closed.
The name of the database to mount or open. If no database name is specified, the database name is taken from the initialization parameter DB_NAME.
Signifies that the database can only be mounted and opened by the current instance (it cannot be opened simultaneously by multiple instances). Cannot be used with SHARED, PARALLEL, or NOMOUNT. If no mounting option is specified, EXCLUSIVE is assigned by default.
Must be specified if the database is to be mounted by multiple instances concurrently. Cannot be used with EXCLUSIVE or NOMOUNT. Invalid if the initialization parameter SINGLE_PROCESS is set to TRUE.
Synonym for PARALLEL.
Specifies that opening the database should be attempted every five seconds if the instance is busy being recovered by another instance. When an instance is being recovered by another instance, the down instance cannot open the database until recovery is complete. If the database cannot be opened for any other reason, RETRY does not attempt to open the database again. This option is only available for instances operating in PARALLEL mode. The number of times RETRY attempts to start the database can be set with the SET RETRIES command (refer to "SET" for the option, RETRIES integer | INFINITE on page B-24 ).
Examples
To start an instance using the standard parameter file, mount the default database in exclusive mode, and open the database, enter:STARTUP
or enter: STARTUP OPEN databasename EXCLUSIVE
To start an instance using the standard parameter file, mount the default database in parallel mode, and open the database, enter:STARTUP PARALLEL
STARTUP OPEN databasename PARALLEL
To restart an instance that went down in parallel mode and may not yet have been recovered by other instances, use the RETRY option: STARTUP PARALLEL RETRY
To shut down the current instance, immediately restart it without mounting or opening, and allow only database administrators to connect, enter:STARTUP FORCE NOMOUNT RESTRICT
To start an instance using the parameter file TESTPARM without mounting the database, enter:STARTUP PFILE=testparm NOMOUNT
To shut down a particular database, immediately restart and open it in parallel mode, allow access only to database administrators, and use the parameter file MYINIT.ORA. enter:STARTUP OPEN databasename PFILE=myinit.ora FORCE SHARED RESTRICT
To start up an instance and mount but not open a database, you can use the following sequence of commands (the system's response is also shown): CONNECT INTERNAL
Connected.
STARTUP NOMOUNT
Oracle instance started.
ALTER DATABASE MOUNT
Statement processed.
At this point, you could run a maintenance command and then open the database, as shown in the following commands: ALTER DATABASE ARCHIVELOG;
Statement processed.
ALTER DATABASE OPEN;
Statement processed.
VARIABLE
Purpose
Declare a bind variable for use in the current session with the EXECUTE or PRINT command, or for use with a PL/SQL block. Prerequisites
None. Syntax
VARIABLE command ::=
The name of the bind variable you wish to define.
The datatype of the bind variable. The valid datatypes are NUMBER, CHAR, and VARCHAR2. You can specify a length from 1 to 255 for CHAR, and from 1 to 2,000 for VARCHAR2. If you do not specify a length, CHAR and VARCHAR2 default to the current setting of CHARWIDTH. Usage Notes
Bind variables defined with the VARIABLE command exist until the end of the session. Variables defined in your session cannot be accessed or changed by a different session.
In V6 compatibility mode, a CHAR variable is variable length, rather than fixed.
VARIABLE balance NUMBER VARIABLE ename CHAR(20)
![]() ![]() Prev Next |
![]() Copyright © 1996 Oracle Corporation. All Rights Reserved. |
![]() Library |
![]() Product |
![]() Contents |
![]() Index |