Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

Use SERIAL

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 to create a table athlete_idx where athlete numbers and names are stored and to create the instances by using a serial order_no.

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

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

INSERT INTO athlete_idx VALUES (order_no.NEXT_VALUE, 'Kim');

INSERT INTO athlete_idx VALUES (order_no.NEXT_VALUE, 'Choo');

INSERT INTO athlete_idx VALUES (order_no.NEXT_VALUE, 'Lee');SELECT * FROM athlete_idx;

 

         code  name

===================================

        10000  'Park'

        10002  'Kim'

        10004  'Choo'

        10006  'Lee'

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.