we use one function for dump table data into another database table is DBLINK
CREATE OR REPLACE FUNCTION dblink(text, text)
RETURNS SETOF record AS
'$libdir/dblink', 'dblink_record'
LANGUAGE c VOLATILE STRICT;
ALTER FUNCTION dblink(text, text)
OWNER TO system;
then we write query to do this task
INSERT INTO tablename
SELECT * FROM dblink('host=ip address dbname=databasename user=userid password=pwd port=portno ','select * from tablename')
AS (column names );
run the above query we get all the data in table is copied into another database table with same name and same columns.
CREATE OR REPLACE FUNCTION dblink(text, text)
RETURNS SETOF record AS
'$libdir/dblink', 'dblink_record'
LANGUAGE c VOLATILE STRICT;
ALTER FUNCTION dblink(text, text)
OWNER TO system;
then we write query to do this task
INSERT INTO tablename
SELECT * FROM dblink('host=ip address dbname=databasename user=userid password=pwd port=portno ','select * from tablename')
AS (column names );
run the above query we get all the data in table is copied into another database table with same name and same columns.
No comments:
Post a Comment