snippetsqlMinor
How to INSERT row in another database/schema in MySQL
Viewed 0 times
insertdatabasemysqlanotherhowrowschema
Problem
Let's say I have the following database/schema setup with the following tables:
How do I insert rows in another schema's table? The following does not seem to work:
How is it possible to insert rows in another another schema?
SCHEMA_1 (default):
TABLE_1
SCHEMA_2:
TABLE_2How do I insert rows in another schema's table? The following does not seem to work:
INSERT INTO TABLE_2 (...) VALUES(...)How is it possible to insert rows in another another schema?
Solution
It should be fully qualified table name means DatabaseName.TableName
In your case it will be
This will insert all rows from
In your case it will be
Insert into schema1.table1 (select * from schema2.table2);This will insert all rows from
schema2.table2 to schema1.table1Code Snippets
Insert into schema1.table1 (select * from schema2.table2);Context
StackExchange Database Administrators Q#16302, answer score: 2
Revisions (0)
No revisions yet.