i want to divide one Table(tbl1) in 2 table(tbl1,tbl2):
for this i use this statements:
tbl1 have these filds:
Code:
CREATE TABLE `tbl1` (
`tbl1_id` int(10) unsigned NOT NULL default '0' auto_increment,
`tbl2_id` int(10) unsigned NOT NULL default '0',
`tbl1_txt` varchar(100) NOT NULL default '',
`tbl1_num` int(20) NOT NULL default 0,
PRIMARY KEY (`tbl1_id`)
)
i ADD tbl2_id to this table and fill it with this statement:
Code:
UPDATE `tbl1` SET `tbl2_id` = tbl1_id ;
first create tbl2:
Code:
CREATE TABLE `tbl2` (
`tbl2_id` int(10) unsigned NOT NULL default '0' auto_increment,
`tbl2_txt` varchar(100) NOT NULL default '',
PRIMARY KEY (`tbl2_id`)
)
& then copy data from tbl1 to tbl2 in this way:
Code:
INSERT INTO tbl2
(tbl2_id, tbl2_txt)
SELECT
tbl1_id, tbl1_txt
FROM
tbl1;
& then DROP some feilds from tbl1.
note that i want to make a relation bet. tbl1 & tbl2 with tbl2_id field.
& the problem is that i cant copy tbl1_id values into the tbl2_id because of being
auto_increment.
this problem occur in Linux OS, i haven't this prob. in windows OS.