The project has a need to store images to the database. You need to create a new table to take this opportunity to learn how to create an Oracle table and set the auto-increment of primary keys in the table.
The project has a need to store images to the database. You need to create a new table to take this opportunity to learn how to create an Oracle table and set the auto-increment of primary keys in the table.
The project has a need to store images to the database. You need to create a new table to take this opportunity to learn how to create an Oracle table and set the auto-increment of primary keys in the table.
First, create the tables required for the project:
Create table Device_Photo (
Device_PhotoID number (4) primary key,
Work_id number (10 ),
COL_115 varchar2 (20 ),
Photo1 blob,
Photo1_save_date date,
Photo2 blob,
Photo2_save_date date,
Photo3 blob,
Photo3_save_date date,
Photo4 blob,
Photo4_save_date date,
Photo5 blob,
Photo5_save_date date,
Create_date date,
Comments varchar2 (20)
);
Apart from the slightly different data types, the creation of Oracle tables is basically the same as that of SQL SERVER, which is relatively simple.
The following is a problem: Setting auto-increment for the primary key in Oracle. The implementation in SQL server is relatively simple, but Oracle does not provide similar methods. I checked the information, sequence is required to set auto-increment for primary keys in Oracle.
Sequence is a unique feature in Oracle that is used to generate a unique continuous sequence of numbers. The sequence is generally used as a primary key.
Create a sequence SEQ_Device_Photo
Create sequence SEQ_Device_Photo
Minvalue 1
Nomaxvalue
Start with 1
Increment by 1
Nocycle
Cache 20;
The usage and query results are as follows: