programing

시퀀스를 제거하는 방법은?

newsource 2023. 9. 7. 21:44

시퀀스를 제거하는 방법은?

아래mariadb-10.3.7InnoDB 엔진에서 저는 다음과 같은 구조를 가지려고 합니다.

drop sequence if exists user_account_id_seq;
create sequence user_account_id_seq start with 1 increment by 10;
drop table if exists user_account;
create table user_account (
  -- id bigint(20) unsigned not null auto_increment,
  id bigint(20) unsigned not null default (next value for user_account_id_seq),
  version int(10) unsigned not null,
  created_on datetime,
  updated_on datetime,
  firstname varchar(255) not null,
  lastname varchar(255) not null,
  password varchar(100),
  password_salt varchar(50),
  readable_password varchar(50),
  email varchar(50) not null,
  confirmed_email bit(1) not null check (confirmed_email in (0, 1)),
  work_phone varchar(20),
  unique key email (email),
  primary key (id)
);

하지만 시퀀스를 제거하고 싶지는 않습니다.

--------------
drop sequence if exists user_account_id_seq
--------------

--------------
commit
--------------

--------------
create sequence user_account_id_seq start with 1 increment by 10
--------------

ERROR 1050 (42S01) at line 4: Table '`useraccount`.`user_account_id_seq`' already exists
+ /usr/bin/mariadb/install/bin/mysql useraccount --protocol=tcp -h mysql -P 3306 -u root -v
--------------

그런 다음 이 메시지가 얼마나 혼란스러운지 보여주기 위해 수동으로 이 명령을 시도했습니다.

MariaDB [useraccount]> create sequence user_account_id_seq start with 1 increment by 10;
ERROR 1813 (HY000): Tablespace for table '`useraccount`.`user_account_id_seq`' exists. Please DISCARD the tablespace before IMPORT
MariaDB [useraccount]> alter table `useraccount`.`user_account_id_seq` discard tablespace; 
ERROR 1146 (42S02): Table 'useraccount.user_account_id_seq' doesn't exist

언급URL : https://stackoverflow.com/questions/54328219/how-to-remove-a-sequence