I'm working with a table of trades where the number of the trade and the year it was created are a composite primary key. I am generating the trade number using AUTO_INCREMENT and taking the current year with php , however, I would like for example, when the year 2017 came to an end, the to start again. For the letter 01 of the year 2018 is different from the letter 01 of the year 2017. My table is this:
CREATE TABLE oficio (
numero int AUTO_INCREMENT,
ano int,
interessado varchar(100),
assunto text,
CONSTRAINT pk_NumeroAno PRIMARY KEY(numero,ano)
);
I've read about the command:
ALTER TABLE oficio AUTO_INCREMENT = 1;
But for it to work, I need to delete all the information in the table. How can I reset AUTO_INCREMENTE without losing data?