Couldn't find reference from sequence to this column

I created a table and added a self-increasing sequence to the primary key
When I used the “truncate” statement before using the “drop table” statement, I found that I couldn’t delete the table, I get an error: “couldn’t find reference from sequence to this column”
Why is that?

Hi @757430916,

Do you mean you ran something like this?

TRUNCATE foo;
DROP TABLE foo; # error: “couldn’t find reference from sequence to this column”

According to the TRUNCATE documentation it drops the table and recreates a new table with the same name.

However TRUNCATE is not transactional, so it runs in the background as a schema change. If you ran the DROP TABLE right after the TRUNCATE (as shown above) it’s possible TRUNCATE was not finished creating the new table with the same name yet.

Does that match the behavior you saw?

I think the main reason is that I added the autoincrement sequence. If I did not add the autoincrement sequence, I could “drop table”.

Hey @757430916 - this seems to be a bug. I created this issue for tracking, please feel free to add additional details and follow on github: https://github.com/cockroachdb/cockroach/issues/29010