Use as per below, you have made db and tablename as a single name encsoling by db.table
.
INSERT INTO test2.key_word SELECT * from test.key_word;
Note: Make sure no of columns should be same in source and target table.
Frage
Please have a look at the following code
INSERT INTO `test2.key_word` SELECT * from `test.key_word`
I am using PHPMyAdmin. This query simply gives the error No Database Selected
when run inside the server 127.0.0.1
area. If I run this inside query inside the SQL Query in test2.key_word
, then it says Table 'test2.test2.key_word' doesn't exist
.
Below is how the test.key_word
table is created
CREATE TABLE `key_word` (
`primary_key` bigint(20) NOT NULL AUTO_INCREMENT,
`indexVal` int(11) NOT NULL,
`hashed_word` char(3) NOT NULL,
PRIMARY KEY (`primary_key`),
KEY `hashed_word` (`hashed_word`,`indexVal`)
) ENGINE=InnoDB AUTO_INCREMENT=28570982 DEFAULT CHARSET=latin1
Below is how the test2.key_word
table is created
CREATE TABLE `key_word` (
`primary_key` bigint(20) NOT NULL,
`indexVal` int(11) NOT NULL,
`hashed_word` char(3) NOT NULL,
PRIMARY KEY (`primary_key`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Why this is not getting copied? Please help.
Lösung
Use as per below, you have made db and tablename as a single name encsoling by db.table
.
INSERT INTO test2.key_word SELECT * from test.key_word;
Note: Make sure no of columns should be same in source and target table.