2
I noticed that when I have a column with auto_increment
, I have to declare the columns on INSERT
.
For example, I created this test table:
create table teste(
id int auto_increment,
nome varchar(100) not null,
valor decimal(5,2),
constraint id_pk primary key (id));
I wanted to be able to enter the data without declaring the columns, as in this example:
insert into teste values ('Danilo',333.33)
But he does not understand, and in the end I have to declare so:
insert into teste (nome,valor) values ('Danilo',333.33)
My question is whether I can make one INSERT
without declaring all columns, like using a reserved word or something that Mysql understands.
If you are adding values to all table columns, you do not need to specify column names in the query. However, make sure the order of the values is in the same order as the columns in the table.
– user60252
Insert into test values (','Danilo',333.33)
– user60252