Home > database >  How to solve the insert information, ID repeat result in an error problem?
How to solve the insert information, ID repeat result in an error problem?

Time:01-21

Is like that, I need from A, B, C three different table, according to the demand to insert data into the "data backup table, no problem, when writing their own select statement at the beginning start insert after we have A problem, 'data backup table', 'id' is the only non-empty primary keys, and that A few tables respective to the the backup list 'id' import not line, the guide into the normal, because will be imported after the 'id' repeat an error,

The 'id' I should be how to processing? Can directly use in the insert statement, or can only use the stored procedure to solve it? (id is 123, this feeling is automatically generated)

PS : A, B, C tables and 'data backup tables are the customer's table, so you can't move the table structure, A few tables

CodePudding user response:

A new field in the bai, an id is set to the backup table primary key id, an id is set to the id used to store the customer table id

CodePudding user response:

I think a \ b \ c three tables of id, cannot be inserted into the table inside the primary key of the data backup id, should be a backup in the table there is a special store other table primary key field, if not then this a backup list, storing three tables of data, the design is not reasonable

CodePudding user response:

refer to the second floor February 16 response:
I think a \ b \ c three tables of id, cannot be inserted into the table inside the primary key of the data backup id, should be a backup in the table there is a special store other table primary key field, if not then this a backup list, storing three tables of data, the design is not reasonable


I also feel strange, unless A, B, C three tables ID determine right from the start is not repeated, but now I have see the serial number of ID, repeat, so I now wants the effect of this: such as A table with ID1, 2, 3 pilot came in, I hope that B table guide came in direct starting from 4, and so on, make it after see the effect again,

CodePudding user response:

reference 1/f, kun jins kao kun jins kao response:
bai, a new field in an id is set to the backup table primary key id, an id is set to the id that is used to store the customer table id

Can write the general processing statement? This part of the backup table id

CodePudding user response:

The ALTER TABLE backup list ADD the customer TABLE _ID INT
When insert the customer table id is inserted into the customer table _ID this field bai

CodePudding user response:

refer to 6th floor kun jins kao kun jins kao response:
ALTER TABLE backup list ADD the customer TABLE _ID INT
When insert the id is inserted into the customer table 'customers table _ID' this field bai


"Well, what I mean is generated on the ID, but I can't write this statement

CodePudding user response:

refer to 7th floor weixin_49130380 response:
Quote: refer to the sixth floor kun jins kao kun jins kao response:
ALTER TABLE backup TABLE ADD customer TABLE _ID INT
When insert the id is inserted into the customer table 'customers table _ID' this field bai


"Well, what I mean is generated on the ID, but I can't write this statement

Keep the customer id?

CodePudding user response:

refer to the eighth floor kun jins kao kun jins kao response:
Quote: refer to 7th floor weixin_49130380 response:
Quote: refer to the sixth floor kun jins kao kun jins kao response:
ALTER TABLE backup TABLE ADD customer TABLE _ID INT
When insert the id is inserted into the customer table 'customers table _ID' this field bai


"Well, what I mean is generated on the ID, but I can't write this statement

Keep the customer id?


No, first 'data backup table is the main, I want to make on the ID

CodePudding user response:

references 9 f weixin_49130380 response:
Quote: refer to the eighth floor kun jins kao kun jins kao response:
Quote: refer to 7th floor weixin_49130380 response:
Quote: refer to the sixth floor kun jins kao kun jins kao response:
ALTER TABLE backup TABLE ADD customer TABLE _ID INT
When insert the id is inserted into the customer table 'customers table _ID' this field bai


"Well, what I mean is generated on the ID, but I can't write this statement

Keep the customer id?


No, first 'data backup table is the main, I want to make the ID on the

The ALTER TABLE data backup TABLE DROP the COLUMN of data backup TABLE's ID COLUMN
The ALTER TABLE data backup TABLE ADD [ID column of the data backup TABLE] INT IDENTITY (1, 1)
Delete the column reconstruction bai, don't insert and then insert the customer table id,
Or you alone and another column to store the customer table id

CodePudding user response:

Really not line, you insert the data in table called fixed prefix plus in front of each table ID
  • Related