Home > database >  Mysql insert ignore into insert only once
Mysql insert ignore into insert only once

Time:10-27

INSERT IGNORE INTO joint_csdn_active (id, app, CSDN, create_time)
VALUES
(
Null,
'12154545',
'DADJSFASFASJFLK'
Unix_timestamp (now ()
)

Id primary key, index app + CSDN, straight into a repeated statements that timestamp things always change, why only insert one?

Change the timestamp to fixed value 1579059360, repeat just insert a, also IGNORE determine the associated with the index?
INSERT IGNORE INTO joint_csdn_active (id, app, CSDN, create_time)
VALUES
(
Null,
'12154545',
'DADJSFASFASJFLK'
1579059360
)

CodePudding user response:

Id is the growth?

Remove the id column in the SQL
INSERT IGNORE INTO joint_csdn_active (app, CSDN, create_time)
VALUES
(
'12154545',
'DADJSFASFASJFLK'
1579059360
)

CodePudding user response:

Id is the increase of, remove after repeat just insert a,

CodePudding user response:

Index app + CSDN
This index is built by the joint only index?

CodePudding user response:

The joint unique index is built

CodePudding user response:

So every time the app + CSD is' 12154545 ', 'DADJSFASFASJFLK'
And then be ignore a

Joint index of the data to change, or only the app + CSD, don't add one and only

CodePudding user response:

Ignore judge row data is based on a unique index to judge?

CodePudding user response:

refer to 6th floor AiHhan response:
ignore judge row data is based on a unique index to judge?


Yes,

Allows you to delete the id column at the beginning, because of the primary key is the only index
  • Related