Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 | 

Accessing and Updating Serials

Description

You can access and update a serial by serial name and a reserved word pair.

Syntax

serial_identifier.CURRENT_VALUE
serial_identifier.NEXT_VALUE

  • serial_identifier.CURRENT_VALUE : Returns the current serial value.
  • serial_identifier.NEXT_VALUE : Increments the serial value and returns the result.
Example

The following is an example of using serial.
First, the athlete_idx table which includes athlete codes and names is created, and one instance created by the order_no serial is inserted.

CREATE TABLE athlete_idx
(code INT, name VARCHAR(40) );

INSERT INTO athlete_idx VALUES (order_no.NEXT_VALUE, 'Park Tae-Hwan');

Caution
  • When you use a serial for the first time after creating it, NEXT_VALUE returns the initial value. Subsequently, the sum of the current value and the increment are returned.