MySQL at column value

I have a table in which the first column is auto_increment. I want to insert data into a table, but skip the first column, because it is automatically updated when a new row starts. So:

INSERT INTO table VALUES (NULL,"lady","gaga","rulz");

But NULL cannot be inserted into a column, as I indicated earlier. What do I need to replace NULL so that nothing is inserted in the column?

+3
source share
3 answers

Just make sure you provide the appropriate column names

INSERT INTO table (col1, col2, col3) VALUES ("lady","gaga","rulz");

You do not even need to fill in all the columns (if they are not required), i.e.

INSERT INTO table (col2) VALUES ("gaga");
+5
source
insert into table(field1, field2, field3) values('lady', 'gaga', 'sucks')
+3
source

.

INSERT INTO table (field2, field3, field4) VALUES ("lady","gaga","rulz");

BTW, , (, , / ), , / - .

Also, you know something will be inserted into field (here) field1 . When you define or modify a table schema, the specified field may be null or not, and / or it may have a default value or not. In the above SQL, you can only omit values ​​for fields that are either nullified or have a default value; Otherwise, SQL returns an error and will not insert any part of the new record.

0
source

Source: https://habr.com/ru/post/1723387/


All Articles