77 lines
3.1 KiB
MySQL
77 lines
3.1 KiB
MySQL
|
BEGIN;
|
||
|
|
||
|
CREATE TABLE IF NOT EXISTS sirene_stock_etablissement (
|
||
|
siren VARCHAR(9),
|
||
|
nic VARCHAR(5),
|
||
|
siret VARCHAR(14),
|
||
|
statutDiffusionEtablissement VARCHAR(1),
|
||
|
dateCreationEtablissement VARCHAR(19),
|
||
|
trancheEffectifsEtablissement VARCHAR(2),
|
||
|
anneeEffectifsEtablissement VARCHAR(19),
|
||
|
activitePrincipaleRegistreMetiersEtablissement VARCHAR(6),
|
||
|
dateDernierTraitementEtablissement VARCHAR(19),
|
||
|
etablissementSiege VARCHAR(5),
|
||
|
nombrePeriodesEtablissement NUMERIC(2),
|
||
|
complementAdresseEtablissement VARCHAR(38),
|
||
|
numeroVoieEtablissement VARCHAR(4),
|
||
|
indiceRepetitionEtablissement VARCHAR(4),
|
||
|
typeVoieEtablissement VARCHAR(4),
|
||
|
libelleVoieEtablissement VARCHAR(100),
|
||
|
codePostalEtablissement VARCHAR(5),
|
||
|
libelleCommuneEtablissement VARCHAR(100),
|
||
|
libelleCommuneEtrangerEtablissement VARCHAR(100),
|
||
|
distributionSpecialeEtablissement VARCHAR(26),
|
||
|
codeCommuneEtablissement VARCHAR(5),
|
||
|
codeCedexEtablissement VARCHAR(9),
|
||
|
libelleCedexEtablissement VARCHAR(100),
|
||
|
codePaysEtrangerEtablissement VARCHAR(5),
|
||
|
libellePaysEtrangerEtablissement VARCHAR(100),
|
||
|
complementAdresse2Etablissement VARCHAR(38),
|
||
|
numeroVoie2Etablissement VARCHAR(4),
|
||
|
indiceRepetition2Etablissement VARCHAR(4),
|
||
|
typeVoie2Etablissement VARCHAR(4),
|
||
|
libelleVoie2Etablissement VARCHAR(100),
|
||
|
codePostal2Etablissement VARCHAR(5),
|
||
|
libelleCommune2Etablissement VARCHAR(100),
|
||
|
libelleCommuneEtranger2Etablissement VARCHAR(100),
|
||
|
distributionSpeciale2Etablissement VARCHAR(26),
|
||
|
codeCommune2Etablissement VARCHAR(5),
|
||
|
codeCedex2Etablissement VARCHAR(9),
|
||
|
libelleCedex2Etablissement VARCHAR(100),
|
||
|
codePaysEtranger2Etablissement VARCHAR(5),
|
||
|
libellePaysEtranger2Etablissement VARCHAR(100),
|
||
|
dateDebut VARCHAR(19),
|
||
|
etatAdministratifEtablissement VARCHAR(1),
|
||
|
enseigne1Etablissement VARCHAR(50),
|
||
|
enseigne2Etablissement VARCHAR(50),
|
||
|
enseigne3Etablissement VARCHAR(50),
|
||
|
denominationUsuelleEtablissement VARCHAR(100),
|
||
|
activitePrincipaleEtablissement VARCHAR(6),
|
||
|
nomenclatureActivitePrincipaleEtablissement VARCHAR(8),
|
||
|
caractereEmployeurEtablissement VARCHAR(1)
|
||
|
);
|
||
|
|
||
|
|
||
|
COPY sirene_stock_etablissement FROM '/docker-entrypoint-initdb.d/StockEtablissement_utf8.csv' DELIMITER ',' CSV HEADER;
|
||
|
|
||
|
-- Index sur la colonne siren
|
||
|
CREATE INDEX idx_siren ON sirene_stock_etablissement (siren);
|
||
|
|
||
|
-- Index sur la colonne siret
|
||
|
CREATE INDEX idx_siret ON sirene_stock_etablissement (siret);
|
||
|
|
||
|
-- Index sur la colonne codePostalEtablissement
|
||
|
CREATE INDEX idx_codePostalEtablissement ON sirene_stock_etablissement (codePostalEtablissement);
|
||
|
|
||
|
-- Index sur la colonne libelleCommuneEtablissement
|
||
|
CREATE INDEX idx_libelleCommuneEtablissement ON sirene_stock_etablissement (libelleCommuneEtablissement);
|
||
|
|
||
|
-- Index sur la colonne activitePrincipaleEtablissement
|
||
|
CREATE INDEX idx_activitePrincipaleEtablissement ON sirene_stock_etablissement (activitePrincipaleEtablissement);
|
||
|
|
||
|
-- ALTER TABLE ONLY sirene_stock_etablissement
|
||
|
-- ADD CONSTRAINT sirene_stock_etablissement_pkey PRIMARY KEY (siren);
|
||
|
|
||
|
COMMIT;
|
||
|
|
||
|
ANALYZE sirene_stock_etablissement;
|