ordre sql
This commit is contained in:
75
postgresql-entrypoint-initdb.d/01_initdb.sql
Normal file
75
postgresql-entrypoint-initdb.d/01_initdb.sql
Normal file
@@ -0,0 +1,75 @@
|
||||
show server_version;
|
||||
select * from pg_available_extensions;
|
||||
|
||||
create schema postgis;
|
||||
create extension if not exists postgis schema postgis;
|
||||
create extension if not exists pgrouting schema postgis;
|
||||
|
||||
create schema ext;
|
||||
create extension if not exists ltree schema ext;
|
||||
create extension if not exists pgcrypto schema ext;
|
||||
|
||||
create schema pgtap;
|
||||
create extension if not exists pgtap schema pgtap;
|
||||
|
||||
create table adherent (
|
||||
id int primary key,
|
||||
nom text,
|
||||
prenom text,
|
||||
genre smallint,
|
||||
naissance date,
|
||||
codepostal text
|
||||
);
|
||||
|
||||
create table famille (
|
||||
code text primary key,
|
||||
famille text,
|
||||
code_parent text, -- references famille(code)
|
||||
arborescence ext.ltree
|
||||
);
|
||||
|
||||
create table article (
|
||||
code text primary key,
|
||||
article text,
|
||||
famille_code text, -- references famille(code)
|
||||
factpoids boolean,
|
||||
unitevente int,
|
||||
prix decimal,
|
||||
suivistock int
|
||||
);
|
||||
|
||||
create table ticket (
|
||||
id int primary key,
|
||||
date_ticket timestamp,
|
||||
adherent_id int, -- references adherent(id)
|
||||
mode_rglt int
|
||||
);
|
||||
|
||||
create table ligne (
|
||||
id int primary key,
|
||||
ticket_id int, --references ticket (id),
|
||||
article_code text, -- references article (code)
|
||||
prix_unitaire decimal,
|
||||
quantite decimal
|
||||
);
|
||||
|
||||
alter table ligne
|
||||
add column total decimal generated always as (prix_unitaire * quantite) stored;
|
||||
|
||||
create table marque (
|
||||
id int primary key,
|
||||
marque text not null
|
||||
);
|
||||
|
||||
create table fournisseur (
|
||||
id int primary key,
|
||||
fournisseur text not null
|
||||
);
|
||||
|
||||
create table region (
|
||||
id int primary key,
|
||||
region text not null
|
||||
);
|
||||
|
||||
insert into region values
|
||||
(1, 'Est'), (2, 'Ouest');
|
||||
Reference in New Issue
Block a user