Oracle database experiment report three tables and completeness definition

Experiment three table and complete definition

-by QQC from BTBU

【Purpose】

1. Master the method of Oracle to create tables, including adding primary keys and foreign keys.
2. Familiar with Oracle's definition of integrity constraints.
[Experimental content]
Open the command line to start the oracle service to connect to the hr user...
Open the command line to start the oracle service to connect to the hr user...

1. The structure of the table BOOK is as follows, please create the table under the HR user

Field name Chinese interpretation Data type
ISBN Book number CHAR(10)
BOOKNAME Book name CHAR
PUBLISH Publisher VARCHAR2(20)
PRICE Book price DECIMAL(20)
AUTHOR Author CHAR
PUBDATE Publication time VARCHAR2(20)
REMARKS Description VARCHAR2(50)

The structure of the table BOOK is as follows, please create the table under the HR user

2. Modify the BOOK table created in the previous step. Add the PUBLISHID column, the type is VARCHAR2 (20), and delete the column PUBLISH.
Modify the BOOK table created in the previous step.  Add the PUBLISHID column, the type is VARCHAR2 (20), and delete the column PUBLISH.

3. Add a primary key constraint to the BOOK table, the primary key is ISBN.
Add a primary key constraint to the BOOK table, the primary key is ISBN.

4. Create a new table PUBLISHINFO, its structure is as follows, the primary key is PUBLISHID.
Field name Chinese interpretation Data type
PUBLISHID Publisher number VARCHAR(20)
PUBLISHNAME Publisher name VARCHAR(30)

Create a new table PUBLISHINFO, its structure is as follows, the primary key is PUBLISHID.  Field name Chinese interpretation Data type PUBLISHID publisher number VARCHAR(20) PUBLISHNAME publisher name VARCHAR(30)

5. Add a foreign key constraint to the BOOK table, the foreign key is PUBLISHID, and the main table is the PUBLISHINFO table.
Add a foreign key constraint to the BOOK table, the foreign key is PUBLISHID, and the main table is the PUBLISHINFO table

6. Add integrity constraints to the BOOK table, where BOOKNAME is non-empty and unique; the value of PRICE is between 10 and 100.
Add integrity constraints to the BOOK table, where BOOKNAME is non-empty and unique; the value of PRICE is between 10 and 100

7. Delete the BOOK table and PUBLISHINFO table.
Delete the BOOK table and PUBLISHINFO table

Guess you like

Origin blog.csdn.net/AQ_No_Happy/article/details/110789189