"Oracle Getting Started" Part 03 Oracle Database Installation

This article introduces how to install the Oracle 19c database on the Windows 10 platform, as well as the creation of sample tables and initialization data used in the column.

3.1 Download Oracle

We download the Oracle software through the official website and open the Oracle database software download page :

download
Select the ZIP file corresponding to Microsoft Windows x64 (64-bit), agree to the Oracle agreement and click download; if you need to log in to an Oracle account, you can register for one for free.

3.2 Install Oracle

Unzip the downloaded zip file, and note that the directory cannot have special characters or Chinese. Then run the setup.exe file in the directory to install:

step 1
The first step remains unchanged, that is, to create and configure a single-instance database, click the "Next" button:

Step 2
In the second step, you can select the database system type. If you use it yourself, you can use the "desktop class". The "server class" takes up more resources. Continue to click the "Next" button:

Step 3
Step 3 Select the owner of the Oracle home directory (that is, the directory where the zip file is decompressed), you can keep it still, and click the "Next" button directly:

Step 4
Step 4 is used to set the Oracle base directory (place data files, configuration files, etc.), database version, character set, global database name, super administrator (sys and system) password and other information. Check "Create as a container database" and enter an insertable database name. This is the database actually used by our application. Remember the information you entered and click the "Next" button:

Step 5
Next, the installation program will perform a prerequisite check to ensure that the current environment meets the installation conditions, and the above summary information will be displayed if there is no problem. Click "Save Response File" to save this installation template, and then click the "Install" button to install:

Step 6
Then the installation program will perform the installation and initial configuration of the Oracle database, and the following interface will be displayed after completion:

Step 7
After the installation is complete, several Oracle services will be created by default and set to start at boot:

service

3.3 Connect to the database

In order to facilitate the connection to the hrdb database, we add a service name. Open the file D:\Applications\WINDOWS.X64_193000_db_home\network\admin\tnsnames.ora (under the decompression directory of the zip file), and add the following content at the end of the file:

HRDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = hrdb)
    )
  )

Click the "SQL Plus" tool in the Oracle directory in the start menu, which is an official command line client:

sqlplus
Enter "system@hrdb" as the user name, and the password is the password we set during the installation process. If the connection is successful, the Oracle database version will be displayed.

In the development process, we usually use graphical user tools. You can install the official Oracle SQL Developer or other tools, such as Dbeaver .

3.4 Create a sample table

We generally do not use the super administrator as the user of the application to connect to the database, but create a dedicated user. In the SQL Plus window above, execute the following command to create a new user (the user name I used is tony, you can create your own user):

SQL> create user tony identified by tony;

用户已创建。

SQL> grant dba to tony;

授权成功。

Later, we can use this user to connect to the database for development.

Next, we install the sample tables and initialization data mainly used in the column. The script can be downloaded on GitHub . We mainly use three tables: employee table (employee), department table (department) and position table (job). The following is their structure diagram, also known as Entity-Relational Diagram:

erd

  • The department table (department) contains the fields of department number (deptid) and department name (deptname). The primary key is the department number. The table has a total of 6 data.
  • The job table (job) contains the job id (jobid) and job title (jobtitle) fields. The primary key is the job number. The table has a total of 10 data.
  • The employee table (employee) contains fields such as employee number (empid) and employee name (empname), the primary key is the employee number, the deptid field is the foreign key that references the department table, and the jobid field is the reference job table The foreign key of the manager number (manager) field is a foreign key that refers to the employee table itself. The table has a total of 25 data.

We only need to run the content in the create_table.sql script to create a table, run the content in the load_data_Oracle_and_PostgreSQL.sql script to initialize the data, and run the content in the drop_table.sql script to delete the table and data.

After the creation is successful, you can test the data:

SELECT emp_id, emp_name, sex, hire_date, salary, email
FROM employee
WHERE emp_id <= 3;

EMP_ID|EMP_NAME  |SEX|HIRE_DATE          |SALARY|EMAIL                |
------|----------|---|-------------------|------|---------------------|
     1|刘备      ||2000-01-01 00:00:00| 30000|liubei@shuguo.com    |
     2|关羽      ||2000-01-01 00:00:00| 26000|guanyu@shuguo.com    |
     3|张飞      ||2000-01-01 00:00:00| 24000|zhangfei@shuguo.com  |

With the environment ready, we can officially start learning SQL statements.

Guess you like

Origin blog.csdn.net/horses/article/details/109372713