---
title: 新增一个 case-V3.1.5-OceanBase 数据库文档-分布式数据库使用文档
description: 分布式数据库OceanBase 社区版文档中心，提供关于新增一个 case的相关内容，方便用户更好的应用分布式数据库OceanBaseOceanBase 数据库
image: https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*OSPzQ6GUQF4AAAAAQHAAAAgAeiGDAQ/original
---
[OceanBase AI 数据大会](https://www.oceanbase.com/conference2026 "OceanBase AI 数据大会")文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*P8CuR4UJ_FkAAAAAAAAAAAAADiGDAQ/original) OceanBase 数据库分布式版 - V 3.1.5 社区版

# 新增一个 case

更新时间：2026-07-01 13:44:58

[编辑](https://github.com/oceanbase/oceanbase-doc/edit/V3.1.5/zh-CN/1800.supporting-tools/1000.mysqltest/200.use-of-case/100.add-a-case.md)  

本文介绍如何新增 case 和 case 示例说明。

## 操作步骤

以 version 测试集为例，在 test_suite/version 中新增版本相关的测试 case，详细步骤如下：

> **说明**
>
>  
>
> 假设我们测试 create table like 这个功能，case 文件名最好能反映测试点，比如 create_table_like_syntax.test 为语法级别的测试。

1. 进入 test 目录：

   ```bash
   cd oceanbase/test

   ```
 2. 输入 case 文件的内容：

   ```bash
   vi mysql_test/test_suite/version/t/sample.test

   ```
 3. 生产结果文件：

   ```bash
   obd test mysqltest <deploy name> --test-set version.sample --record

   ```
 4. 人工校验结果文件后（这步也可以通过执行与 MySQL 的对比来完成）:

   ```bash
   mv mysql_test/test_suite/version/r/mysql/sample.record mysql_test/test_suite/version/r/mysql/sample.result

   ```
 5. 再运行检查一遍：

   ```bash
   obd test mysqltest <deploy name> --test-set version.sample

   ```
 6. 提交时注意 git add 的时候要同时提交 test 文件和 result 文件。

## 示例

以 `sequence_sql_demo_mysql.test` 为例，这个 case 主要目的是测试 sequence 基本功能。其中井号（#）开头的行内容为备注说明。

### case 文件

```sql
purge recyclebin;
let $char_charset = 'utf8';
--disable_warnings
drop database IF EXISTS oblrp;
--enable_warnings
create database oblrp;
use oblrp;
set timestamp = 1600000000;
set ob_trx_timeout = 10000000000;
set ob_query_timeout = 10000000000;
--result_format 4

--echo 查询序列
--error 0,1051
drop table t1;
create table tt1(id int);
insert into tt1 values(1);

--error 0,1051
drop table a;
create table a (id int, name varchar(30), pk_id int);
insert into a values(1,'name01',1);
insert into a values(2,'name02',1);
insert into a values(3,'name03',2);
insert into a values(4,'name04',3);
insert into a values(5,'name05',3);
insert into a values(6,'name06',3);
--error 0,1051
drop table b;
create table b (id int, name varchar(30));
insert into b values(1,'name01');
insert into b values(2,'name02');
insert into b values(3,'name03');

--echo 设置序列的属性
--error 0,4298
drop sequence seq_test1;
create sequence seq_test1;
--error 0,4298
drop sequence seq_test2;
create sequence seq_test2 INCREMENT BY 1 start with 1 minvalue 1 maxvalue 5 cycle noorder cache 3;
--error 0,4298
drop sequence seq_test3;
create sequence seq_test3 INCREMENT BY 1 start with 1 minvalue 1 maxvalue 5 nocycle noorder nocache;

--echo 访问序列
select seq_test1.currval from a where id =0;
select seq_test1.nextval from a where id =0;
--error 4201
select seq_test1.currval from a;
select seq_test1.nextval , id ,name from a ;
select seq_test1.currval c ,seq_test1.nextval b from a;
select seq_test2.currval c ,seq_test2.nextval b from a;
--error 4332
select seq_test3.currval c ,seq_test3.nextval b from a;
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id =1;
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id >1;
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id <1;
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id <3;
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id <=2;
select seq_test1.currval c ,seq_test1.nextval b,id ,name from a where pk_id>=2;
select seq_test2.currval c ,seq_test2.nextval b,id ,name from a where pk_id>=1;
select seq_test1.currval c ,seq_test1.nextval b ,a.* from a a where id <>1;
--error 4332
select seq_test3.currval c ,seq_test3.nextval b,id ,name from a where pk_id=3;
select seq_test1.currval c ,seq_test1.nextval b,id ,name from a where pk_id>=2 and id=3;
select seq_test2.currval c ,seq_test2.nextval b,id ,name from a where pk_id>=2 or id=3;
select seq_test1.currval c ,seq_test2.nextval b ,a.* from a a where id between  2 and 3;
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where name like '%name%';
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where name not like '%name%';
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where exists (select * from b);
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where id >any (select id from b);
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where id >all (select id from b);
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where id in (select id from b where name ='name02');
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a left join b b on a.pk_id =b.id;
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a full join b b on a.pk_id =b.id;
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a right join b b on a.pk_id =b.id;
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a inner join b b on a.pk_id =b.id;

--echo 子查询中访问序列

select  (case id when 1 then seq_test1.nextval
when 2 then seq_test2.nextval
else seq_test1.currval end )  e from a;

select  (case id when seq_test1.nextval then 1
when  seq_test1.currval then 2
else 3 end )  e from a;
--error 1054
select * from a group by id,seq_test1.nexval;
--error 4315
select * from a order by id,seq_test1.nextval;
--error 4315
select * from a where seq_test1.nextval>2;
--error 4315
select * from a where seq_test1.currval>2;

select seq_test1.currval+1 from a;
select seq_test1.nextval+1 from a;
select seq_test1.currval+seq_test1.nextval from a;
select seq_test1.nextval+abs(-1) from a;
select seq_test1.currval+abs(-1) from a;
select seq_test1.nextval*2 from a;
select seq_test1.currval*2 from a;
select seq_test1.nextval-2 from a;
select seq_test1.currval-2 from a;
select seq_test1.nextval/3 from a;
select seq_test1.currval/3 from a;
select seq_test1.currval mod seq_test1.nextval from a;
select seq_test1.nextval div seq_test1.currval from a;
select -seq_test1.currval from a;
select -seq_test1.nextval from a;
select +seq_test1.nextval from a;
select +seq_test1.currval from a;

create table  c as select seq_test1.currval,seq_test1.nextval from a;
--disable_result_log
explain select seq_test1.currval,seq_test1.nextval from a;
--enable_result_log

--echo 函数中处理序列
select concat( seq_test1.currval,seq_test1.nextval) from a;
select ascii(seq_test1.nextval) from a;
select length(seq_test1.currval) from a;
select acos(seq_test1.currval) from a;
select pow(seq_test1.nextval,seq_test1.currval) from a;
select cast(seq_test1.currval as time) from a;
select isnull(seq_test1.nextval) from a;
--error 1064
select CURRENT_TIME(seq_test1.nextval) from a;

--error 0,4298
drop sequence seq_test1;
--echo  ########清空回收站，删除测试数据库，表等 ##########
--disable_warnings
drop database  IF EXISTS  oblrp;
--enable_warnings
purge recyclebin;

```

### 预期结果文件

'sequence_sql_demo_mysql.result' 内容如下：

```sql
purge recyclebin;
drop database IF EXISTS oblrp;
create database oblrp;
use oblrp;
set timestamp = 1600000000;
set ob_trx_timeout = 10000000000;
set ob_query_timeout = 10000000000;
result_format: 4
查询序列
drop table t1;
create table tt1(id int);
insert into tt1 values(1);
drop table a;
create table a (id int, name varchar(30), pk_id int);
insert into a values(1,'name01',1);
insert into a values(2,'name02',1);
insert into a values(3,'name03',2);
insert into a values(4,'name04',3);
insert into a values(5,'name05',3);
insert into a values(6,'name06',3);
drop table b;
create table b (id int, name varchar(30));
insert into b values(1,'name01');
insert into b values(2,'name02');
insert into b values(3,'name03');
设置序列的属性
drop sequence seq_test1;
create sequence seq_test1;
drop sequence seq_test2;
create sequence seq_test2 INCREMENT BY 1 start with 1 minvalue 1 maxvalue 5 cycle noorder cache 3;
drop sequence seq_test3;
create sequence seq_test3 INCREMENT BY 1 start with 1 minvalue 1 maxvalue 5 nocycle noorder nocache;
访问序列
select seq_test1.currval from a where id =0;
+---------+
| currval |
+---------+
+---------+
select seq_test1.nextval from a where id =0;
+---------+
| nextval |
+---------+
+---------+
select seq_test1.currval from a;
ERROR HY000: sequence is not yet defined in this session
select seq_test1.nextval , id ,name from a ;
+---------+------+--------+
| nextval | id   | name   |
+---------+------+--------+
|       1 |    1 | name01 |
|       2 |    2 | name02 |
|       3 |    3 | name03 |
|       4 |    4 | name04 |
|       5 |    5 | name05 |
|       6 |    6 | name06 |
+---------+------+--------+
select seq_test1.currval c ,seq_test1.nextval b from a;
+----+----+
| c  | b  |
+----+----+
|  7 |  7 |
|  8 |  8 |
|  9 |  9 |
| 10 | 10 |
| 11 | 11 |
| 12 | 12 |
+----+----+
select seq_test2.currval c ,seq_test2.nextval b from a;
+---+---+
| c | b |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 1 | 1 |
+---+---+
select seq_test3.currval c ,seq_test3.nextval b from a;
ERROR HY000: sequence exceeds MAXVALUE and cannot be instantiated
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id =1;
+----+----+
| c  | b  |
+----+----+
| 13 | 13 |
| 14 | 14 |
+----+----+
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id >1;
+----+----+
| c  | b  |
+----+----+
| 15 | 15 |
| 16 | 16 |
| 17 | 17 |
| 18 | 18 |
+----+----+
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id <1;
+---+---+
| c | b |
+---+---+
+---+---+
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id <3;
+----+----+
| c  | b  |
+----+----+
| 19 | 19 |
| 20 | 20 |
| 21 | 21 |
+----+----+
select seq_test1.currval c ,seq_test1.nextval b from a where pk_id <=2;
+----+----+
| c  | b  |
+----+----+
| 22 | 22 |
| 23 | 23 |
| 24 | 24 |
+----+----+
select seq_test1.currval c ,seq_test1.nextval b,id ,name from a where pk_id>=2;
+----+----+------+--------+
| c  | b  | id   | name   |
+----+----+------+--------+
| 25 | 25 |    3 | name03 |
| 26 | 26 |    4 | name04 |
| 27 | 27 |    5 | name05 |
| 28 | 28 |    6 | name06 |
+----+----+------+--------+
select seq_test2.currval c ,seq_test2.nextval b,id ,name from a where pk_id>=1;
+---+---+------+--------+
| c | b | id   | name   |
+---+---+------+--------+
| 2 | 2 |    1 | name01 |
| 3 | 3 |    2 | name02 |
| 4 | 4 |    3 | name03 |
| 5 | 5 |    4 | name04 |
| 1 | 1 |    5 | name05 |
| 2 | 2 |    6 | name06 |
+---+---+------+--------+
select seq_test1.currval c ,seq_test1.nextval b ,a.* from a a where id <>1;
+----+----+------+--------+-------+
| c  | b  | id   | name   | pk_id |
+----+----+------+--------+-------+
| 29 | 29 |    2 | name02 |     1 |
| 30 | 30 |    3 | name03 |     2 |
| 31 | 31 |    4 | name04 |     3 |
| 32 | 32 |    5 | name05 |     3 |
| 33 | 33 |    6 | name06 |     3 |
+----+----+------+--------+-------+
select seq_test3.currval c ,seq_test3.nextval b,id ,name from a where pk_id=3;
ERROR HY000: sequence exceeds MAXVALUE and cannot be instantiated
select seq_test1.currval c ,seq_test1.nextval b,id ,name from a where pk_id>=2 and id=3;
+----+----+------+--------+
| c  | b  | id   | name   |
+----+----+------+--------+
| 34 | 34 |    3 | name03 |
+----+----+------+--------+
select seq_test2.currval c ,seq_test2.nextval b,id ,name from a where pk_id>=2 or id=3;
+---+---+------+--------+
| c | b | id   | name   |
+---+---+------+--------+
| 3 | 3 |    3 | name03 |
| 4 | 4 |    4 | name04 |
| 5 | 5 |    5 | name05 |
| 1 | 1 |    6 | name06 |
+---+---+------+--------+
select seq_test1.currval c ,seq_test2.nextval b ,a.* from a a where id between  2 and 3;
+----+---+------+--------+-------+
| c  | b | id   | name   | pk_id |
+----+---+------+--------+-------+
| 34 | 2 |    2 | name02 |     1 |
| 34 | 3 |    3 | name03 |     2 |
+----+---+------+--------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where name like '%name%';
+----+---+---------+------+--------+-------+
| c  | b | currval | id   | name   | pk_id |
+----+---+---------+------+--------+-------+
| 34 | 4 |       4 |    1 | name01 |     1 |
| 34 | 5 |       5 |    2 | name02 |     1 |
| 34 | 1 |       1 |    3 | name03 |     2 |
| 34 | 2 |       2 |    4 | name04 |     3 |
| 34 | 3 |       3 |    5 | name05 |     3 |
| 34 | 4 |       4 |    6 | name06 |     3 |
+----+---+---------+------+--------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where name not like '%name%';
+---+---+---------+------+------+-------+
| c | b | currval | id   | name | pk_id |
+---+---+---------+------+------+-------+
+---+---+---------+------+------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where exists (select * from b);
+----+---+---------+------+--------+-------+
| c  | b | currval | id   | name   | pk_id |
+----+---+---------+------+--------+-------+
| 34 | 5 |       5 |    1 | name01 |     1 |
| 34 | 1 |       1 |    2 | name02 |     1 |
| 34 | 2 |       2 |    3 | name03 |     2 |
| 34 | 3 |       3 |    4 | name04 |     3 |
| 34 | 4 |       4 |    5 | name05 |     3 |
| 34 | 5 |       5 |    6 | name06 |     3 |
+----+---+---------+------+--------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where id >any (select id from b);
+----+---+---------+------+--------+-------+
| c  | b | currval | id   | name   | pk_id |
+----+---+---------+------+--------+-------+
| 34 | 1 |       1 |    2 | name02 |     1 |
| 34 | 2 |       2 |    3 | name03 |     2 |
| 34 | 3 |       3 |    4 | name04 |     3 |
| 34 | 4 |       4 |    5 | name05 |     3 |
| 34 | 5 |       5 |    6 | name06 |     3 |
+----+---+---------+------+--------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where id >all (select id from b);
+----+---+---------+------+--------+-------+
| c  | b | currval | id   | name   | pk_id |
+----+---+---------+------+--------+-------+
| 34 | 1 |       1 |    4 | name04 |     3 |
| 34 | 2 |       2 |    5 | name05 |     3 |
| 34 | 3 |       3 |    6 | name06 |     3 |
+----+---+---------+------+--------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a where id in (select id from b where name ='name02');
+----+---+---------+------+--------+-------+
| c  | b | currval | id   | name   | pk_id |
+----+---+---------+------+--------+-------+
| 34 | 4 |       4 |    2 | name02 |     1 |
+----+---+---------+------+--------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a left join b b on a.pk_id =b.id;
+----+---+---------+------+--------+-------+
| c  | b | currval | id   | name   | pk_id |
+----+---+---------+------+--------+-------+
| 34 | 5 |       5 |    1 | name01 |     1 |
| 34 | 1 |       1 |    2 | name02 |     1 |
| 34 | 2 |       2 |    3 | name03 |     2 |
| 34 | 3 |       3 |    4 | name04 |     3 |
| 34 | 4 |       4 |    5 | name05 |     3 |
| 34 | 5 |       5 |    6 | name06 |     3 |
+----+---+---------+------+--------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a full join b b on a.pk_id =b.id;
+----+---+---------+------+--------+-------+
| c  | b | currval | id   | name   | pk_id |
+----+---+---------+------+--------+-------+
| 34 | 1 |       1 |    1 | name01 |     1 |
| 34 | 2 |       2 |    2 | name02 |     1 |
| 34 | 3 |       3 |    3 | name03 |     2 |
| 34 | 4 |       4 |    4 | name04 |     3 |
| 34 | 5 |       5 |    5 | name05 |     3 |
| 34 | 1 |       1 |    6 | name06 |     3 |
+----+---+---------+------+--------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a right join b b on a.pk_id =b.id;
+----+---+---------+------+--------+-------+
| c  | b | currval | id   | name   | pk_id |
+----+---+---------+------+--------+-------+
| 34 | 2 |       2 |    1 | name01 |     1 |
| 34 | 3 |       3 |    2 | name02 |     1 |
| 34 | 4 |       4 |    3 | name03 |     2 |
| 34 | 5 |       5 |    4 | name04 |     3 |
| 34 | 1 |       1 |    5 | name05 |     3 |
| 34 | 2 |       2 |    6 | name06 |     3 |
+----+---+---------+------+--------+-------+
select seq_test1.currval c ,seq_test2.nextval b, seq_test2.currval ,a.* from a inner join b b on a.pk_id =b.id;
+----+---+---------+------+--------+-------+
| c  | b | currval | id   | name   | pk_id |
+----+---+---------+------+--------+-------+
| 34 | 3 |       3 |    1 | name01 |     1 |
| 34 | 4 |       4 |    2 | name02 |     1 |
| 34 | 5 |       5 |    3 | name03 |     2 |
| 34 | 1 |       1 |    4 | name04 |     3 |
| 34 | 2 |       2 |    5 | name05 |     3 |
| 34 | 3 |       3 |    6 | name06 |     3 |
+----+---+---------+------+--------+-------+
子查询中访问序列
select  (case id when 1 then seq_test1.nextval
when 2 then seq_test2.nextval
else seq_test1.currval end )  e from a;
+----+
| e  |
+----+
| 35 |
|  5 |
| 37 |
| 38 |
| 39 |
| 40 |
+----+
select  (case id when seq_test1.nextval then 1
when  seq_test1.currval then 2
else 3 end )  e from a;
+---+
| e |
+---+
| 3 |
| 3 |
| 3 |
| 3 |
| 3 |
| 3 |
+---+
select * from a group by id,seq_test1.nexval;
ERROR 42S22: Unknown column 'seq_test1.nexval' in 'group statement'
select * from a order by id,seq_test1.nextval;
ERROR HY000: sequence number not allowed here
select * from a where seq_test1.nextval>2;
ERROR HY000: sequence number not allowed here
select * from a where seq_test1.currval>2;
ERROR HY000: sequence number not allowed here
select seq_test1.currval+1 from a;
+---------------------+
| seq_test1.currval+1 |
+---------------------+
|                  47 |
|                  47 |
|                  47 |
|                  47 |
|                  47 |
|                  47 |
+---------------------+
select seq_test1.nextval+1 from a;
+---------------------+
| seq_test1.nextval+1 |
+---------------------+
|                  48 |
|                  49 |
|                  50 |
|                  51 |
|                  52 |
|                  53 |
+---------------------+
select seq_test1.currval+seq_test1.nextval from a;
+-------------------------------------+
| seq_test1.currval+seq_test1.nextval |
+-------------------------------------+
|                                 106 |
|                                 108 |
|                                 110 |
|                                 112 |
|                                 114 |
|                                 116 |
+-------------------------------------+
select seq_test1.nextval+abs(-1) from a;
+---------------------------+
| seq_test1.nextval+abs(-1) |
+---------------------------+
|                        60 |
|                        61 |
|                        62 |
|                        63 |
|                        64 |
|                        65 |
+---------------------------+
select seq_test1.currval+abs(-1) from a;
+---------------------------+
| seq_test1.currval+abs(-1) |
+---------------------------+
|                        65 |
|                        65 |
|                        65 |
|                        65 |
|                        65 |
|                        65 |
+---------------------------+
select seq_test1.nextval*2 from a;
+---------------------+
| seq_test1.nextval*2 |
+---------------------+
|                 130 |
|                 132 |
|                 134 |
|                 136 |
|                 138 |
|                 140 |
+---------------------+
select seq_test1.currval*2 from a;
+---------------------+
| seq_test1.currval*2 |
+---------------------+
|                 140 |
|                 140 |
|                 140 |
|                 140 |
|                 140 |
|                 140 |
+---------------------+
select seq_test1.nextval-2 from a;
+---------------------+
| seq_test1.nextval-2 |
+---------------------+
|                  69 |
|                  70 |
|                  71 |
|                  72 |
|                  73 |
|                  74 |
+---------------------+
select seq_test1.currval-2 from a;
+---------------------+
| seq_test1.currval-2 |
+---------------------+
|                  74 |
|                  74 |
|                  74 |
|                  74 |
|                  74 |
|                  74 |
+---------------------+
select seq_test1.nextval/3 from a;
+---------------------+
| seq_test1.nextval/3 |
+---------------------+
|             25.6667 |
|             26.0000 |
|             26.3333 |
|             26.6667 |
|             27.0000 |
|             27.3333 |
+---------------------+
select seq_test1.currval/3 from a;
+---------------------+
| seq_test1.currval/3 |
+---------------------+
|             27.3333 |
|             27.3333 |
|             27.3333 |
|             27.3333 |
|             27.3333 |
|             27.3333 |
+---------------------+
select seq_test1.currval mod seq_test1.nextval from a;
+-----------------------------------------+
| seq_test1.currval mod seq_test1.nextval |
+-----------------------------------------+
|                                       0 |
|                                       0 |
|                                       0 |
|                                       0 |
|                                       0 |
|                                       0 |
+-----------------------------------------+
select seq_test1.nextval div seq_test1.currval from a;
+-----------------------------------------+
| seq_test1.nextval div seq_test1.currval |
+-----------------------------------------+
|                                       1 |
|                                       1 |
|                                       1 |
|                                       1 |
|                                       1 |
|                                       1 |
+-----------------------------------------+
select -seq_test1.currval from a;
+--------------------+
| -seq_test1.currval |
+--------------------+
|                -94 |
|                -94 |
|                -94 |
|                -94 |
|                -94 |
|                -94 |
+--------------------+
select -seq_test1.nextval from a;
+--------------------+
| -seq_test1.nextval |
+--------------------+
|                -95 |
|                -96 |
|                -97 |
|                -98 |
|                -99 |
|               -100 |
+--------------------+
select +seq_test1.nextval from a;
+---------+
| nextval |
+---------+
|     101 |
|     102 |
|     103 |
|     104 |
|     105 |
|     106 |
+---------+
select +seq_test1.currval from a;
+---------+
| currval |
+---------+
|     106 |
|     106 |
|     106 |
|     106 |
|     106 |
|     106 |
+---------+
create table  c as select seq_test1.currval,seq_test1.nextval from a;
explain select seq_test1.currval,seq_test1.nextval from a;
函数中处理序列
select concat( seq_test1.currval,seq_test1.nextval) from a;
+----------------------------------------------+
| concat( seq_test1.currval,seq_test1.nextval) |
+----------------------------------------------+
| 113113                                       |
| 114114                                       |
| 115115                                       |
| 116116                                       |
| 117117                                       |
| 118118                                       |
+----------------------------------------------+
select ascii(seq_test1.nextval) from a;
+--------------------------+
| ascii(seq_test1.nextval) |
+--------------------------+
|                       49 |
|                       49 |
|                       49 |
|                       49 |
|                       49 |
|                       49 |
+--------------------------+
select length(seq_test1.currval) from a;
+---------------------------+
| length(seq_test1.currval) |
+---------------------------+
|                         3 |
|                         3 |
|                         3 |
|                         3 |
|                         3 |
|                         3 |
+---------------------------+
select acos(seq_test1.currval) from a;
+-------------------------+
| acos(seq_test1.currval) |
+-------------------------+
|                    NULL |
|                    NULL |
|                    NULL |
|                    NULL |
|                    NULL |
|                    NULL |
+-------------------------+
select pow(seq_test1.nextval,seq_test1.currval) from a;
+------------------------------------------+
| pow(seq_test1.nextval,seq_test1.currval) |
+------------------------------------------+
|                   1.2994262207056124e262 |
|                    4.432907660220782e264 |
|                   1.5243074119957227e267 |
|                    5.282945311356653e269 |
|                    1.845323993438539e272 |
|                    6.495847189879201e274 |
+------------------------------------------+
select cast(seq_test1.currval as time) from a;
+---------------------------------+
| cast(seq_test1.currval as time) |
+---------------------------------+
| 00:01:30                        |
| 00:01:30                        |
| 00:01:30                        |
| 00:01:30                        |
| 00:01:30                        |
| 00:01:30                        |
+---------------------------------+
select isnull(seq_test1.nextval) from a;
+---------------------------+
| isnull(seq_test1.nextval) |
+---------------------------+
|                         0 |
|                         0 |
|                         0 |
|                         0 |
|                         0 |
|                         0 |
+---------------------------+
select CURRENT_TIME(seq_test1.nextval) from a;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'seq_test1.nextval) from a' at line 1
drop sequence seq_test1;
########清空回收站，删除测试数据库，表等 ##########
drop database  IF EXISTS  oblrp;
purge recyclebin;

```

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ) 咨询
