There are two methods to create a database in Oracle.
The first is to use Oracle database builder and DBCA, which is a graphical interface and easy to understand because of its friendly and beautiful interface and complete prompts. In Windows, this tool can be opened in the Oracle program group ("START"-"program"-"Oracle OraDb10g_home1"-"Configuration and Migration Tools"-"Database ConfigurationAssistant "), you can also directly enter dbca in the command line ("START"-"run"-"cmd") tool.
Another method is to create a database manually. This is what we will talk about below. Manual database creation is more troublesome than DBCA database creation. However, if we have learned how to manually create a database, we can better understand the architecture of the Oracle database.
Manual database creation requires several steps, each of which is critical. It includes:
1,Create necessary Directories
2,Create an initialization parameter file
3,Set the environment variable Oracle_sid
4,Create an instance
5,Create a password file
6,Start the database to nomount (Instance) Status
7,Execute the database creation script
8,Run catalog to create a data dictionary.
9,Run catproc to create a package
10,Run pupbld
11,Create a spfile file from the initialization parameter file
12,Execute the scott script to create the scott Mode
After completing the above steps, you can use "SQL> alter database open;" to open the normal use of the database.
Next, I will use the above steps as an experiment. Experimental System Platform: Windows Server 2000 Database System Version: Oracle Database 10G Oracle installation path: D Disk.Name of the created database: book
1. Open the command line tool and create related directories.
C:/> mkdir D:/oracle/product/10.1.0/admin/book
C:/> mkdir D:/oracle/product/10.1.0/admin/book/bdump
C:/> mkdir D:/oracle/product/10.1.0/admin/book/udump
C:/> mkdir D:/oracle/product/10.1.0/admin/book/cdump
C:/> mkdir D:/oracle/product/10.1.0/admin/book/pfile
C:/> mkdir D:/oracle/product/10.1.0/admin/book/create
C:/> mkdir D:/oracle/product/10.1.0/oradata/book
You can also create a directory on the GUI of Windows. Where
D:/oracle/product/10.1.0/admin/bookThe subdirectories are used to store tracking information during database operation. The two most important sub-directories are the bdump and udump directories. The bdump directory stores the tracking information of various background processes in the database's dynamic process. The alert file is a warning file, the file name is called alert_book.log. When a database encounters a problem, you can first view the file to find out the cause. You can also find the cause of various problems during manual creation. The Udump directory stores trace information related to specific sessions. D: The/oracle/product/10.1.0/oradata/book directory stores various database files, including control files, data files, and redo log files.
2Create an initialization parameter file
When starting the database system, you must use the initialization parameter file settings to allocate memory and start necessary background processes. Therefore, whether the initialization parameter file is created correctly or whether the parameter settings are correct is related to the "fate" of the entire database ". To create an initialization parameter file, you can copy the current initialization parameter file and modify it as needed.
Manually write it out in one sentence, because the structure of the initialization parameter file is basically the same. When we install Oracle, the system has installed a database named orcl for us, so we can get an initialization parameter file from it. Open D:/oracle/product/10.1.0/admin/orcl/pfile and find init. ora file, copy it to D:/oracle/product/10.1.0/bd_1/databse, and rename it initbook. ora. Open initbook. ora in notepad and modify the following content: db_domain = ""
Db_name = book
Control_files = ("D:/oracle/product/10.1.0/oradata/book/control01.ctl ",
"D:/oracle/product/10.1.0/oradata/book/control02.ctl ",
"D:/oracle/product/10.1.0/oradata/book/control03.ctl") undo_management = AUTO
Undo_tablespace = UNDOTBS1
――Note that the "UNDOTBS1" here must correspond to the database creation step.
Background_dump_dest = D:/oracle/product/10.1.0/admin/book/bdump
Core_dump_dest = D:/oracle/product/10.1.0/admin/book/cdump
User_dump_dest = D:/oracle/product/10.1.0/admin/book/udump
3. Open the command line and set the environment variable oracle_sid.
C:/> set oracle_sid = bookBy default, environment variables are set to the database instance operated in the command line as book.
4. Create an instance (that is, the background Control Service)
C:/> oradim-new-sid book oradimIs the name of the tool program used to create an instance.-new indicates that the new instance is executed,-delete indicates that the instance is deleted, and-sid indicates the name of the victim instance.
5. Create a password file
C:/> orapwd file = D:/oracle/product/10.1.0/db_1/database/pwdbook. ora password = bookstore entries = 2
OrapwdIt is the name of the Worker Program that creates the password file. The file parameter specifies the Directory and name of the password file, and the password parameter specifies the password of the sys user, the entries parameter specifies the number of users with DBA permissions in the database. Of course, there is also a force parameter. I believe you do not mean it, so I will not detail it here. Note that the command here requires a line of input, and line breaks are not allowed in the middle; otherwise, unnecessary errors may occur. The password file is used to store the password of a sys user. Because a sys user is responsible for creating a database, starting a database, and shutting down the database, the password file is separately stored in the password file as a sys user, in this way, password verification can also be performed when the database is opened at the end.