MySQL中的 create sequence 错误
我在Windows下面安装了一个MySQL,然后我尝试在里面创建一个sequence,使用create sequence语句,但是失败,说语法错误
mysql不支持类似pgsql那样的sequence类型,你可以在建表的时候建一个自增长的字段,例如:
create table test
(
id int auto_increment primary key
#其他字段定义
)type=myisam;
id的作用就相当于一个sequence了 :)
mysql创建序列sequence 和触发器的例子
mysql> create table animals(id int not null auto_increment primary key, name cha
r(32) not null);
Query OK, 0 rows affected (0.08 sec)
mysql> insert into animals(name) values ('dog'), ('cat');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from animals;
+----+------+
| id | name |
+----+------+
| 1 | dog |
| 2 | cat |
+----+------+
2 rows in set (0.00 sec)
本文介绍了在MySQL中尝试使用createsequence语句创建序列时遇到的问题,并解释了MySQL并不支持类似于PostgreSQL的sequence类型。文中提供了使用自增长字段作为替代方案的方法,并通过一个具体的例子展示了如何实现。
1716

被折叠的 条评论
为什么被折叠?



