db:postgresql
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
| db:postgresql [2020/08/04 13:55] – [Importar y exportar] grillo | db:postgresql [2020/12/09 16:06] (actual) – [Debug] grillo | ||
|---|---|---|---|
| Línea 22: | Línea 22: | ||
| $ ps -ef | grep " | $ ps -ef | grep " | ||
| ``` | ``` | ||
| + | |||
| + | VER SERVIDOR AL QUE ESTOY CONECTADO | ||
| + | ``` | ||
| + | \conninfo | ||
| + | ``` | ||
| + | ``` | ||
| + | SELECT CURRENT_USER usr, :' | ||
| + | ``` | ||
| + | ``` | ||
| + | SELECT inet_server_addr() ip, inet_server_port() port; | ||
| + | ``` | ||
| + | |||
| Línea 41: | Línea 53: | ||
| $ psql -U prueba -h localhost -W -d dbprueba | $ psql -U prueba -h localhost -W -d dbprueba | ||
| $ psql -U prueba -h localhost -W " | $ psql -U prueba -h localhost -W " | ||
| + | ``` | ||
| + | |||
| + | usuario " | ||
| + | ``` | ||
| + | $ psql -U prueba -h localhost -W " | ||
| + | ``` | ||
| + | |||
| + | |||
| + | LISTAR ESQUEMAS DE UNA BASE | ||
| + | ``` | ||
| + | postgres=# \dp | ||
| + | postgres=# select schema_name from information_schema.schemata; | ||
| + | ``` | ||
| + | |||
| + | VER ESQUEMA ACTUAL | ||
| + | ``` | ||
| + | postgres=# SHOW search_path; | ||
| + | ``` | ||
| + | |||
| + | CONECTARSE A UN ESQUEMA | ||
| + | ``` | ||
| + | postgres=# SET search_path TO myschema, | ||
| ``` | ``` | ||
| Línea 95: | Línea 129: | ||
| VER TABLAS DE LA BASE | VER TABLAS DE LA BASE | ||
| - | ``` postgres=# \dt ``` | + | ``` |
| - | ``` mydb=# SELECT * FROM " | + | postgres=# \dt |
| + | mydb=# SELECT * FROM " | ||
| + | ``` | ||
| VER TABLAS LISTAS Y SECUENCIAS DE LA BASE | VER TABLAS LISTAS Y SECUENCIAS DE LA BASE | ||
| - | ``` postgres=# \d ``` | + | ``` |
| + | postgres=# \d | ||
| + | ``` | ||
| CAMBIAR DUEÑO DE UNA TABLA | CAMBIAR DUEÑO DE UNA TABLA | ||
| + | |||
| tabla " | tabla " | ||
| - | ``` mydb=# | + | ``` |
| + | mydb=# | ||
| + | ``` | ||
| Línea 231: | Línea 272: | ||
| ``` | ``` | ||
| $ kill procpid | $ kill procpid | ||
| + | ``` | ||
| + | |||
| + | |||
| + | VER USUARIOS CONECTADOS A UNA BASE labase | ||
| + | ``` | ||
| + | mydb=# SELECT usename, | ||
| ``` | ``` | ||
| Línea 260: | Línea 307: | ||
| ``` | ``` | ||
| + | |||
| + | ## Actualizar datos con unl desde pc sin acceso al filesystem | ||
| + | |||
| + | Procedimiento para actualizar datos tomándolos desde un archivo csv|unl ubicado en una pc cliente del servidor. La limitación es que el comando `copy` sólo levanta archivos del filesystem local del servidor. | ||
| + | ``` | ||
| + | cat / | ||
| + | objeto_id | ||
| + | tipo_objeto | ||
| + | objeto | ||
| + | acta_id | ||
| + | t_acta | ||
| + | nro_acta | ||
| + | serie character varying(2), | ||
| + | fecha_acta | ||
| + | lugar_acta_id | ||
| + | ref_geografica | ||
| + | cant_encontradas | ||
| + | cod_calle | ||
| + | nom_calle | ||
| + | cod_intersec | ||
| + | nom_intersec | ||
| + | altura | ||
| + | letra_a | ||
| + | bis_a boolean, | ||
| + | sec integer, | ||
| + | mnz integer, | ||
| + | gra integer, | ||
| + | div integer, | ||
| + | sdiv | ||
| + | carpeta | ||
| + | catastral | ||
| + | copy from stdin;" | ||
| + | |||
| + | copy tmp_datos_domicilio from stdin delimiter ','; | ||
| + | ``` | ||
| ## Replicación | ## Replicación | ||
| PROCESOS CORRIENDO | PROCESOS CORRIENDO | ||
| + | |||
| en el master | en el master | ||
| - | ``` $ ps -ef | grep sender ``` | + | ``` |
| + | $ ps -ef | grep sender | ||
| + | ``` | ||
| en el esclavo | en el esclavo | ||
| - | ``` $ ps -ef | grep receiver ``` | + | ``` |
| + | $ ps -ef | grep receiver | ||
| + | ``` | ||
| ESTADO DE LA REPLICA | ESTADO DE LA REPLICA | ||
| - | ``` $ pg_lsclusters ``` | + | ``` |
| + | $ pg_lsclusters | ||
| + | ``` | ||
| VER ESCLAVOS CONECTADOS AL MASTER | VER ESCLAVOS CONECTADOS AL MASTER | ||
| + | |||
| en el master | en el master | ||
| - | ``` $ psql -c " | + | ``` |
| + | $ psql -c " | ||
| + | ``` | ||
| VER RETRASO EN EL ESCLAVO | VER RETRASO EN EL ESCLAVO | ||
| + | |||
| en el esclavo | en el esclavo | ||
| - | ``` postgres=# select now() - pg_last_xact_replay_timestamp() AS replication_delay; | + | ``` |
| + | postgres=# select now() - pg_last_xact_replay_timestamp() AS replication_delay; | ||
| + | ``` | ||
| | | ||
db/postgresql.1596549307.txt.gz · Última modificación: 2020/08/04 13:55 por grillo