mirror of
https://github.com/fruworg/fruworg.github.io.git
synced 2024-11-16 09:27:17 +03:00
Compare commits
2 Commits
913fc2a56f
...
45ecaf391b
Author | SHA1 | Date | |
---|---|---|---|
45ecaf391b | |||
2791a8cfb8 |
20
content/posts/psql-to-csv.md
Normal file
20
content/posts/psql-to-csv.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: Конвертация PostgreSQL в CSV
|
||||||
|
description: pSQL to CSV
|
||||||
|
date: 2024-09-11T17:24:00+02:00
|
||||||
|
tags: [linux, postgres]
|
||||||
|
---
|
||||||
|
## Конвертация
|
||||||
|
```bash
|
||||||
|
psql -d <database>
|
||||||
|
```
|
||||||
|
```psql
|
||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
r RECORD;
|
||||||
|
BEGIN
|
||||||
|
FOR r IN (SELECT table_name FROM information_schema.tables WHERE table_schema = 'public') LOOP
|
||||||
|
EXECUTE format('COPY %I TO %L WITH (FORMAT CSV, HEADER)', r.table_name, '/<path-to-csv>/' r.table_name '.csv');
|
||||||
|
END LOOP;
|
||||||
|
END $$;
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user