Use COPY TO for dump the table data in csv format.
COPY table TO '/tmp/table.csv' DELIMITER ',';
Use the COPY FROM to "paste" it in another table.
COPY another_table FROM '/tmp/table.csv' DELIMITER ',';
#Using in single model | |
def self.update_or_create(attributes) | |
obj = first || new | |
obj.assign_attributes(attributes) | |
obj | |
end | |
#User.where(email: "a@b.com").update_or_create(email: "d@e.com") | |
Use COPY TO for dump the table data in csv format.
COPY table TO '/tmp/table.csv' DELIMITER ',';
Use the COPY FROM to "paste" it in another table.
COPY another_table FROM '/tmp/table.csv' DELIMITER ',';