Changes between Version 23 and Version 24 of Export table RHT


Ignore:
Timestamp:
Apr 6, 2012 3:33:52 PM (13 years ago)
Author:
celine
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Export table RHT

    v23 v24  
    2626}}} 
    2727 
     28{{{ 
     29/*  
     30SCRIPT DE CREATION D'UN TABLEAU UNIQUE DES RESULTATS  
     316 avril 2012 Cédric Briand Céline Jouanin 
     32*/ 
     33 
     34-- pour voir les données du modèle, ci dessous seules certaines colonnes de résultats sont retenues 
     35 
     36select * from rht.model_mod 
     37 
     38-- le script utilise la fonction crosstab (text,text) pour passer d'un format 'long' a un format 'court' (données en colonnes) 
     39-- comme crosstab est une fonction renvoyant un setof record, il faut nommer et typer les colonnes de sortie as.... 
     40 
     41DROP TABLE IF EXISTS rht.crosstab_rhtvs2; 
     42CREATE TABLE rht.crosstab_rhtvs2 as ( 
     43        SELECT  
     44  rhtvs2.id_drain, 
     45  crosstab.largeur,  
     46  crosstab.surface,  
     47  crosstab.ers_id_drain,  
     48  crosstab.exutoire,  
     49  crosstab.gamma,  
     50  crosstab.delta,  
     51  crosstab.densite,  
     52  crosstab.abondance, 
     53  rhtvs2.the_geom, 
     54  rhtvs2.dmer, 
     55  rhtvs2.dsource, 
     56  rhtvs2.cumnbbar from rht.rhtvs2 left join  
     57        (SELECT * FROM crosstab('select res_id_drain, res_mod_id,res_value from rht.resultmodel 
     58                                        where res_mod_id in (24,23,25,26,4,5,6,27) 
     59                                        order by 1,2', 
     60                                        'select mod_id from rht.model_mod where mod_id in (24,23,25,26,4,5,6,27) order by mod_id') 
     61                        AS ct(id_drain integer,  
     62                        largeur numeric, 
     63                        surface numeric, 
     64                        ers_id_drain numeric, 
     65                        gamma numeric,  
     66                        delta numeric, 
     67                        densite numeric, 
     68                        abondance numeric, 
     69                        exutoire numeric)  
     70        )as crosstab 
     71on rhtvs2.id_drain=crosstab.id_drain); 
     72 
     73comment on table rht.crosstab_rhtvs2 is 'table crée le 6 avril 2012 a partir des résultats définitifs d''EDA'; 
     74-- creation des clés et des index qui vont bien 
     75alter table rht.crosstab_rhtvs2 add constraint c_pk_crosstab_rhtvs2 PRIMARY KEY (id_drain);      
     76CREATE INDEX crosstab_rhtvs2_index 
     77  ON rht.crosstab_rhtvs2 
     78  USING btree 
     79  (id_drain); 
     80CREATE INDEX crosstab_rhtvs2_gistindex 
     81  ON rht.rhtvs2 
     82  USING gist 
     83  (the_geom); 
     84   
     85-- code dump 
     86-- pg_dump -U postgres -f 'v_rht_model_mod.sql' --table rht.crosstab.rhtvs2 eda2.0_RHT 
     87 
     88comment on column rht.crosstab_rhtvs2.surface is 'surface en km²'; 
     89comment on column rht.crosstab_rhtvs2.largeur is 'largeur en m'; 
     90 
     91cd d:\CelineJouanin\export_table\version2 
     92C:\"Program Files"\PostgreSQL\8.4\bin\pg_dump  -U postgres -p 5432 -t rht.crosstab_rhtvs2 eda2.0_RHT> v_rht_model_mod.sql 
     93}}} 
    2894 
    2995== Version 1 rht ==