I want to get data from our production server to my local development server for testing purposes. I was wondering if there is any way by which I can copy records from prod server's db table to my local db table using SQL query. The tables are exactly same in terms of column names and datatypes.
I know that I can do it by taking dump to a fil开发者_高级运维e and then loading using infile. Although I am using MySQL, I would like to know if it is possible to do it in other databases as well and if yes, how?
As for MySQL, probably the easiest way to do with would be with mysqladmin
(link):
mysqladmin create db_name
mysqldump -h 'other_hostname' --compress db_name | mysql db_name
With DB2, you can do this with 3-part table names (subsystem.authid.object
), as long as your DBA has defined access to the remote subsystem.
In order for this to work, the DB2 doing the forwarding must be on Z/OS. DB2 L(inux)U(nix)W(indows) does not support this feature. See here.
The syntax is using INSERT
mostly as with a normal insert:
INSERT INTO table (n1, n2, ... nx)
SELECT n1, n2, ... nx
FROM subsystem.authid.object
WHERE ...
etc.
In case of SQL Server, you can use a simple SELECT INTO
statement if you define a linked server:
SELECT Column1, Column2, ...
INTO dbo.TableName
FROM LinkedServerName.DatabaseName.dbo.TableName
All the major databases have a replication feature, or third party software that implements it. It sounds like you're half a step away from needing all its features, so I'd suggest considering it! http://www.adderpit.com/practical-postgresql/x8695.htm
Hope that helps
It is Possible to insert data from one server database table to another server database table by using many ways (1) Oledb tranfer from the EXPORT and IMPORT utility This is the GUI base utility. (2) by Doing the Linked Server:- To Do this first You have to create a Link server in the Destination database of Source database. Object Explorer => Server Object => Linked Server => New Linked Server => server name and login and the password
And then You can excess the tables of the other database in other server.
精彩评论