Professionnel - Page 11
-
[PostgreSQL] Streaming Replication Monitoring Script
-
[PostgreSQL] repmgr tuto
-
[Oracle] Calculate the lobs size
#!/bin/sh
#script to calculate the lobs size
sqlplus /nolog<<!EOF
conn / as sysdba
spool req1.sql
set head off
set feed off
select 'SELECT max(dbms_lob.getlength('''||col.column_name||''')) from '||col.owner||'.'||col.table_name||';'
from sys.dba_tab_columns col inner join sys.dba_tables t on col.owner = t.owner and col.table_name = t.table_name where col.data_type in ('BLOB', 'CLOB', 'NCLOB', 'BFILE')
and col.owner not in ('GSMADMIN_INTERNAL','OCOR_OWN','AUDSYS','ANONYMOUS','CTXSYS','DBSNMP','EXFSYS', 'LBACSYS', 'MDSYS', 'MGMT_VIEW','OLAPSYS','OWBSYS','ORDPLUGINS', 'ORDSYS','OUTLN', 'SI_INFORMTN_SCHEMA','SYS','SYSMAN','SYSTEM', 'TSMSYS','WK_TEST', 'WKPROXY','WMSYS','XDB','APEX_040000', 'APEX_PUBLIC_USER','DIP', 'WKSYS', 'FLOWS_30000','FLOWS_FILES','MDDATA', 'ORACLE_OCM', 'XS$NULL', 'SPATIAL_CSW_ADMIN_USR', 'SPATIAL_WFS_ADMIN_USR', 'PUBLIC')
;
spool off
exit
!EOF
sqlplus -s / as sysdba @req1.sql -
[PostgreSQL] Anonymisation des données
-
Badge WAICF
-
PostgreSQL Un tour d'horizon !
PostgreSQL around the world
PostgreSQL 16 is out.
https://www.postgresql.org/docs/16/release-16.html
Digging into PostgreSQL iceberg
https://avestura.dev/blog/explaining-the-postgres-meme
PostgreSQL partitioning
https://www.timescale.com/blog/when-to-consider-postgres-partitioning/
Who does PostgreSQL
https://momjian.us/main/blogs/pgblog/2023.html#September_11_2023
-
[Postgres] NEWS
There is some new about PostgreSQL world.
Some useful tricks and tips about PostgreSQL, like how to get unused index list (but so many more like displaying fun smiley instead of blanks for NULL…)
https://www.crunchydata.com/postgres-tips
Some basics about transactions with examples
https://stormatics.tech/salmans-planet-postgresql/how-to-execute-transactions-in-postgresql
Huge progress with replication; implement bi-directional replication with upcoming PostgreSQL 16
-
Découverte d'une base mongodb
mongo -u <USERNAME> -p <PASSWORD> --eval "var DATABASE_NAME='<DATABASE_NAME>'" Source_Discovery_V2.js
-
POSTGRES Backup / restore
Petites bases :
#backup-C : ajouter le create database.
pg_dump -d $DB > $DB.sql
#restore
psql < $DB.sql
Grosses bases :#backup
on exporte la structure :pg_dump -s $DB> $DBstruct.sql
psql $DB < $DBstruct.sql
on exporte les données :
pg_dump -Fc -a -d $DB > $DB.dmp
pg_restore -Fc -d $DB $DB.dmp
Ajout du GZIP pour le dump :
pg_dump -U <user> <database> | gzip -c > backup.gz
Ajout du GZIP pour l'import :
gzip -d backup.gz | psql -d <database> -U <user>You might need to be logged in as
postgres
in order to have full privileges on databases.su - postgres psql -l # will list all databases on Postgres cluster
pg_dump/pg_restore
pg_dump -U username -f backup.dump database_name -Fc
switch
-F
specify format of backup file:c
will use custom PostgreSQL format which is compressed and results in smallest backup file sized
for directory where each file is one tablet
for TAR archive (bigger than custom format)-h
/--host
Specifies the host name of the machine on which the server is running-W
/--password
Forcepg_dump
to prompt for a password before connecting to a database
restore backup:
pg_restore -d database_name -U username -C backup.dump
-
[Postgres] VACUUM
Comprendre : autovacuum_freeze_max_age
Quand le vacuum ne suffit plus pour réinitialiser le XID d'une table, il faut faire un VACUUM FULL de cette table.