Herramientas de usuario

Herramientas del sitio


db:postgresql

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anteriorRevisión previa
Próxima revisión
Revisión previa
db:postgresql [2020/08/18 11:35] grillodb:postgresql [2020/12/09 16:06] (actual) – [Debug] grillo
Línea 22: Línea 22:
 $ ps -ef | grep "postgres: " $ ps -ef | grep "postgres: "
 ``` ```
 +
 +VER SERVIDOR AL QUE ESTOY CONECTADO
 +```
 +\conninfo
 +```
 +```
 +SELECT CURRENT_USER usr, :'HOST' host, inet_server_port() port;
 +```
 +```
 +SELECT inet_server_addr() ip, inet_server_port() port;
 +```
 +
  
  
Línea 43: Línea 55:
 ``` ```
  
-LISTAS ESQUEMAS DE UNA BASE+usuario "prueba" en servidor "localhost" con clave "pepe" en base "dbprueba" con esquema por defecto "pruebaschema" 
 +``` 
 +$ psql -U prueba -h localhost -W "dbname=dbprueba sslmode=require options=--search_path=pruebaschema" 
 +``` 
 + 
 + 
 +LISTAR ESQUEMAS DE UNA BASE
 ``` ```
 postgres=# \dp postgres=# \dp
 postgres=# select schema_name from information_schema.schemata; 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,public;
 ``` ```
  
Línea 244: Línea 272:
 ``` ```
 $ kill procpid $ kill procpid
 +```
 +
 +
 +VER USUARIOS CONECTADOS A UNA BASE labase
 +```
 +mydb=# SELECT usename,client_addr FROM pg_stat_activity WHERE datname = 'labase';
 ``` ```
  
Línea 273: 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  /home/cliente/actas_sin_objeto_para_actualizar.csv| psql "sslmode=require host=postgre.server.com dbname=labase" --username=cliente -W -c "create temp table tmp_datos_domicilio (
 +    objeto_id          bigint,
 +    tipo_objeto        character varying(20),
 +    objeto             character varying(500),
 +    acta_id            bigint,
 +    t_acta             integer,
 +    nro_acta           bigint,
 +    serie              character varying(2),
 +    fecha_acta         timestamp without time zone,
 +    lugar_acta_id      bigint,
 +    ref_geografica     character varying(255),
 +    cant_encontradas   integer,
 +    cod_calle          integer,
 +    nom_calle          character varying(50),
 +    cod_intersec       integer,
 +    nom_intersec       character varying(50),
 +    altura             integer,
 +    letra_a            character varying(5),
 +    bis_a              boolean,
 +    sec                integer,
 +    mnz                integer,
 +    gra                integer,
 +    div                integer,
 +    sdiv               integer,
 +    carpeta            integer,
 +    catastral          character varying(25));
 +copy from stdin;"
 +
 +copy tmp_datos_domicilio from stdin delimiter ',';
 +```
  
 ## Replicación ## Replicación
db/postgresql.1597750536.txt.gz · Última modificación: 2020/08/18 11:35 por grillo