MySQL 15 - Auto Increment (AUTO_INCREMENT)

Поділитися
Вставка
  • Опубліковано 23 жов 2024

КОМЕНТАРІ • 23

  • @andregomes2629
    @andregomes2629 6 років тому +3

    Thanks for knowing exactly when to tell me what I want to hear, when I want to hear it the most.

  • @zeroanims4113
    @zeroanims4113 3 роки тому +2

    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).

  • @colinrhee98
    @colinrhee98 3 роки тому +2

    Love your videos, very concise and helpful.

  • @kidmyn
    @kidmyn 2 роки тому

    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.

  • @mehulvelani9669
    @mehulvelani9669 6 років тому +3

    how do i create a auto increment for a value such as C001 , c001 c003 c004 etc
    and
    start 100 no and the autoinncement

  • @mohammadakbar32
    @mohammadakbar32 7 років тому +1

    Great and clear explanation, Thanks !

  • @eversoneder1
    @eversoneder1 4 роки тому +3

    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

    • @FallenAngel1796
      @FallenAngel1796 4 роки тому

      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.

    • @zeroanims4113
      @zeroanims4113 3 роки тому

      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.

  • @zirelyleon3844
    @zirelyleon3844 3 роки тому

    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.

  • @elmarneudam4471
    @elmarneudam4471 7 років тому +1

    Thanks for the video! It helped me!

  • @xpaiinz8250
    @xpaiinz8250 6 років тому

    Should I use an INT(11) for the id or a guaranteed unique generated string

    • @codebreakthrough
      @codebreakthrough  6 років тому

      IDs should be int

    • @xpaiinz8250
      @xpaiinz8250 6 років тому

      @@codebreakthrough OK so I can imagine for performance and storage reasons int are much lighter but why does Mongo use strings?

  • @viajandoconnofi
    @viajandoconnofi 4 роки тому

    Thank you so much.

  • @_isaac_2317
    @_isaac_2317 2 роки тому

    My tables say Null whenever I try and use Auto increment instead of using numbers

  • @jenniferward6821
    @jenniferward6821 3 роки тому

    Ok so where do you explain how to auto increment???

  • @tojoeinstein5558
    @tojoeinstein5558 Рік тому

    how to make number ID with text in sql like this P0001?

  • @andregomes2629
    @andregomes2629 6 років тому

    awesome job

  • @AdenRozen
    @AdenRozen 7 років тому

    very good tanks
    :')

  • @nguyenlenguyen4337
    @nguyenlenguyen4337 3 роки тому

    ai đó có thể vietsub giúp tôi với TT

  • @kdl868
    @kdl868 7 років тому +2

    how do i create a auto increment for a value such as C001 , c001 c003 c004 etc