The Oracle Startup Command
The Oracle Startup Command
SQL> startup
ORACLE instance started.
* Startup (nomount)
* Mount
* Open
When you issue the startup command, the first thing the
database will do is enter the nomount stage. During the nomount
stage,
Oracle first opens and reads the initialization parameter file
(init.ora) to see how the database is configured. For example,
the sizes of all of the memory areas in Oracle are defined within
the parameter file.
When the startup command enters the mount stage, it opens and
reads the control file.
The control file is a binary file that tracks important database
information, such as the location of the database data files.
If you have already started the database instance with the startup
nomount command, you might change it from the nomount to
mount startup stage using the alter database command:
The last startup step for an Oracle database is the open stage.
When Oracle opens the database, it accesses all of the datafiles
associated with the database.
Once it has accessed the database data files, Oracle makes sure
that all of the database
Data files are consistent.
SQL> startup
You can take the database in and out of restricted mode with the
alter database command as seen in this example:
* Defines the columns in the table and the data types of those
columns
Connect scott/tiger
Once you create a table, you can use the SQL*Plus desc
command to see its structure as seen in this example:
SQL>desc books
Name Null? Type
----------------------------------------- -------- ------------
BOOK_ID NOT NULL NUMBER
BOOK_ID_SEQ NOT NULL NUMBER
BOOK_NAME VARCHAR2 (30)
AUTHOR_NAME VARCHAR2 (40)
BOOK_ISBN VARCHAR2 (20)
TABLESPACE users;
------------------------------Altering Tables--------------------------
Having created tables, you will find there are times that you will
want to alter them in some respect. This is done with the alter
table command.
Some things you might find you need to do with the alter table
command include:
SQL>ALTER TABLE
books
ADD
(
book_pub_no NUMBER,
book_alt_title VARCHAR2 (50)
);
It used to be in Oracle that renaming or removing a column from
a table was a big deal.
You actually had to save the data, drop and re-create the table
which can have a horrible impact if it’s a big table in a
production environment. Now, you can rename or drop columns
from a table with the alter table command.
-----------------------------Dropping Tables----------------------------
The drop table command allows you to drop tables from your
Oracle database.
A good exercise for you might be to try to join this query with a
view like DBA_EXTENTS and figure out just how big these
tables are allocated.
SQL> startup
SQL> shutdown
When you execute a shutdown, Oracle will flush all the changes
in memory out to the database data files. This makes database
startup quicker because the database is in a consistent state.
Think of it this way: if you jump into the air and land on your
feet, you have landed in a way that prepares you to make
another jump. If, instead, you jump and land on your back, you
are in no position to make another jump; instead, you must
perform a recovery by taking the actions required to stand again.
A clean shutdown is one that is prepared to come back up
without delay.
A dirty shutdown is one that lands on its back; it can not come
back up without first recovering itself.
* Control files
* Parameter files
Database data files are physical files stored on disk. These files
are used to store data on disk. Database data files are only
written to by the DBWR processes that we introduced you to
earlier
(There is an exception or two to this statement, but for now,
assume that this point this true).
Think of the online redo logs like a tape recorder that records
every change in the Oracle database. As changes occur, they are
regularly recorded in the online redo logs, just like you might
record a movie on your VCR.
In the event that a disk crashes, you may have to replace the disk
and restore the disk data from a backup tape. If this backup tape
was several days ago, you have lost a lot of data.
* Alert log - This is the general log file for each Oracle
database.