in 1:23 actually it will take the highest value that ever existed in the table and add + 1 to it. For example let's say we have a table called Users and the row with the highest ID (let's say ID 1008) got deleted, now the current highest ID in the table would be the ID of the previous record, let's say that is ID 1007. Now let's say that record also got deleted, now the current highest ID would be 1006. If you insert a new record to the Users table, the ID of that will actually be 1009 because 1008 was the highest ID that ever existed, and not the highest_value_in_the_table + 1 (1006 + 1 = 1007).
Thanks for the great video. I wanted to ask, I am trying to import a .csv file from excel with a "landlord_id" column. In the rows it says AUTO_INCREMENT, but every time I import it into MySQL, it comes out as just text. When I change the data type to INT, it won't import my data. What gives? Appreciate your time.
how to keep id(Auto Increment) sequence after deleting one entry? in another words, id | name 01 | John 02 | Dean 03 | Bob Dean was deleted, then: 01 | John 03 | Bob I want this, but automatic without manually changing id's every time a person is deleted: 01 | John 02 | Bob something like >get the deleted id number >go to every next id entry and subtract the id by 1 or something like that
I don't think that's something you can do; the id is supposed to be unique, and there is really no downside to having missing id values (i.e. deleted records). More so, if you happened to have a relatonal table that related to your table (Say, a table connected to users), and you changed some user's id value, all the relations would be altered, and you would have to update every instance of a record in every table where the modified user's id is present. I would advice to just let the auto increment to its thing and just live with the fact that there when you delete a record you lose that possible id value.
That just violates the rule that primary keys should be immutable or should never change. What you want to do is actually dangerous and there is no point in doing that.
Hi, I need that the values for a ColumnID, which is a Primary Key, to start at 100 and increment by 5. How can I do that in MySQL? Hope you could help me. Thanks.
Thanks for knowing exactly when to tell me what I want to hear, when I want to hear it the most.
in 1:23 actually it will take the highest value that ever existed in the table and add + 1 to it.
For example let's say we have a table called Users and the row with the highest ID (let's say ID 1008) got deleted, now the current highest ID in the table would be the ID of the previous record, let's say that is ID 1007. Now let's say that record also got deleted, now the current highest ID would be 1006. If you insert a new record to the Users table, the ID of that will actually be 1009 because 1008 was the highest ID that ever existed, and not the highest_value_in_the_table + 1 (1006 + 1 = 1007).
Love your videos, very concise and helpful.
Thanks for the great video. I wanted to ask, I am trying to import a .csv file from excel with a "landlord_id" column. In the rows it says AUTO_INCREMENT, but every time I import it into MySQL, it comes out as just text. When I change the data type to INT, it won't import my data. What gives?
Appreciate your time.
how do i create a auto increment for a value such as C001 , c001 c003 c004 etc
and
start 100 no and the autoinncement
Great and clear explanation, Thanks !
how to keep id(Auto Increment) sequence after deleting one entry? in another words,
id | name
01 | John
02 | Dean
03 | Bob
Dean was deleted, then:
01 | John
03 | Bob
I want this, but automatic without manually changing id's every time a person is deleted:
01 | John
02 | Bob
something like
>get the deleted id number
>go to every next id entry and subtract the id by 1
or something like that
I don't think that's something you can do; the id is supposed to be unique, and there is really no downside to having missing id values (i.e. deleted records).
More so, if you happened to have a relatonal table that related to your table (Say, a table connected to users), and you changed some user's id value, all the relations would be altered, and you would have to update every instance of a record in every table where the modified user's id is present.
I would advice to just let the auto increment to its thing and just live with the fact that there when you delete a record you lose that possible id value.
That just violates the rule that primary keys should be immutable or should never change. What you want to do is actually dangerous and there is no point in doing that.
Hi, I need that the values for a ColumnID, which is a Primary Key, to start at 100 and increment by 5. How can I do that in MySQL? Hope you could help me. Thanks.
Thanks for the video! It helped me!
Should I use an INT(11) for the id or a guaranteed unique generated string
IDs should be int
@@codebreakthrough OK so I can imagine for performance and storage reasons int are much lighter but why does Mongo use strings?
Thank you so much.
My tables say Null whenever I try and use Auto increment instead of using numbers
Ok so where do you explain how to auto increment???
how to make number ID with text in sql like this P0001?
awesome job
very good tanks
:')
ai đó có thể vietsub giúp tôi với TT
how do i create a auto increment for a value such as C001 , c001 c003 c004 etc
Yes I also want to know how to do this