MyTetra Share
Делитесь знаниями!
Скрипт с примером подготовки набора таблиц для базы данных
Время создания: 13.07.2018 15:30
Автор: Mikhail "Velonski" Eremeev
Текстовые метки: postgresql example script
Раздел: Postgresql
Запись: Velonski/mytetra-database/master/base/14815152308jsiksy4m6/text.html на raw.githubusercontent.com

--

-- PostgreSQL database dump

--


-- Dumped from database version 9.5.4

-- Dumped by pg_dump version 9.5.4


SET statement_timeout = 0;

SET lock_timeout = 0;

SET client_encoding = 'UTF8';

SET standard_conforming_strings = on;

SET check_function_bodies = false;

SET client_min_messages = warning;

SET row_security = off;


--

-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:

--


CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--

-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:

--


COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';


SET search_path = public, pg_catalog;


SET default_tablespace = '';


SET default_with_oids = false;


--

-- Name: categories; Type: TABLE; Schema: public; Owner: sotoshop

--


CREATE TABLE categories (

id integer NOT NULL,

name character varying NOT NULL

);


ALTER TABLE categories OWNER TO sotoshop;


--

-- Name: cost_formulas; Type: TABLE; Schema: public; Owner: sotoshop

--


CREATE TABLE cost_formulas (

id integer NOT NULL,

category_id integer NOT NULL,

formula_current character varying,

formula_top character varying,

formula_bottom character varying

);


ALTER TABLE cost_formulas OWNER TO sotoshop;


--

-- Name: items; Type: TABLE; Schema: public; Owner: sotoshop

--


CREATE TABLE items (

id integer NOT NULL,

category_id integer NOT NULL,

article integer NOT NULL,

name character varying NOT NULL,

"exists" boolean NOT NULL,

cost_whole numeric(25,2),

cost_recommend numeric(25,2),

cost_seller numeric(25,2),

update_time timestamp(5) with time zone NOT NULL

);


ALTER TABLE items OWNER TO sotoshop;


--

-- Name: seq_categories_id; Type: SEQUENCE; Schema: public; Owner: sotoshop

--


CREATE SEQUENCE seq_categories_id

START WITH 1

INCREMENT BY 1

NO MINVALUE

NO MAXVALUE

CACHE 1;


ALTER TABLE seq_categories_id OWNER TO sotoshop;


--

-- Name: seq_categories_id; Type: SEQUENCE OWNED BY; Schema: public; Owner: sotoshop

--


ALTER SEQUENCE seq_categories_id OWNED BY categories.id;


--

-- Name: seq_cost_formulas_id; Type: SEQUENCE; Schema: public; Owner: sotoshop

--


CREATE SEQUENCE seq_cost_formulas_id

START WITH 1

INCREMENT BY 1

NO MINVALUE

NO MAXVALUE

CACHE 1;


ALTER TABLE seq_cost_formulas_id OWNER TO sotoshop;


--

-- Name: seq_cost_formulas_id; Type: SEQUENCE OWNED BY; Schema: public; Owner: sotoshop

--


ALTER SEQUENCE seq_cost_formulas_id OWNED BY cost_formulas.id;


--

-- Name: seq_items_id; Type: SEQUENCE; Schema: public; Owner: sotoshop

--


CREATE SEQUENCE seq_items_id

START WITH 1

INCREMENT BY 1

NO MINVALUE

NO MAXVALUE

CACHE 1;


ALTER TABLE seq_items_id OWNER TO sotoshop;


--

-- Name: seq_items_id; Type: SEQUENCE OWNED BY; Schema: public; Owner: sotoshop

--


ALTER SEQUENCE seq_items_id OWNED BY items.id;


--

-- Name: id; Type: DEFAULT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY categories ALTER COLUMN id SET DEFAULT nextval('seq_categories_id'::regclass);


--

-- Name: id; Type: DEFAULT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY cost_formulas ALTER COLUMN id SET DEFAULT nextval('seq_cost_formulas_id'::regclass);


--

-- Name: id; Type: DEFAULT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY items ALTER COLUMN id SET DEFAULT nextval('seq_items_id'::regclass);


--

-- Data for Name: categories; Type: TABLE DATA; Schema: public; Owner: sotoshop

--


COPY categories (id, name) FROM stdin;

\.


--

-- Data for Name: cost_formulas; Type: TABLE DATA; Schema: public; Owner: sotoshop

--


COPY cost_formulas (id, category_id, formula_current, formula_top, formula_bottom) FROM stdin;

\.


--

-- Data for Name: items; Type: TABLE DATA; Schema: public; Owner: sotoshop

--


COPY items (id, category_id, article, name, "exists", cost_whole, cost_recommend, cost_seller, update_time) FROM stdin;

\.


--

-- Name: seq_categories_id; Type: SEQUENCE SET; Schema: public; Owner: sotoshop

--


SELECT pg_catalog.setval('seq_categories_id', 1, false);


--

-- Name: seq_cost_formulas_id; Type: SEQUENCE SET; Schema: public; Owner: sotoshop

--


SELECT pg_catalog.setval('seq_cost_formulas_id', 1, false);


--

-- Name: seq_items_id; Type: SEQUENCE SET; Schema: public; Owner: sotoshop

--


SELECT pg_catalog.setval('seq_items_id', 1, false);


--

-- Name: categories_pkey; Type: CONSTRAINT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY categories

ADD CONSTRAINT categories_pkey PRIMARY KEY (id);


--

-- Name: cost_formulas_pkey; Type: CONSTRAINT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY cost_formulas

ADD CONSTRAINT cost_formulas_pkey PRIMARY KEY (id);


--

-- Name: cst_cost_formulas_category_id_unique; Type: CONSTRAINT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY cost_formulas

ADD CONSTRAINT cst_cost_formulas_category_id_unique UNIQUE (category_id);


--

-- Name: cst_unique_categories_name; Type: CONSTRAINT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY categories

ADD CONSTRAINT cst_unique_categories_name UNIQUE (name);


--

-- Name: cst_unique_items_article; Type: CONSTRAINT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY items

ADD CONSTRAINT cst_unique_items_article UNIQUE (article);


--

-- Name: cst_unique_items_name; Type: CONSTRAINT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY items

ADD CONSTRAINT cst_unique_items_name UNIQUE (name);


--

-- Name: items_pkey; Type: CONSTRAINT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY items

ADD CONSTRAINT items_pkey PRIMARY KEY (id);


--

-- Name: fk_cost_formulas_category_id_categories_id; Type: FK CONSTRAINT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY cost_formulas

ADD CONSTRAINT fk_cost_formulas_category_id_categories_id FOREIGN KEY (category_id) REFERENCES categories(id) ON UPDATE CASCADE ON DELETE CASCADE;


--

-- Name: fk_items_category_id_categories_id; Type: FK CONSTRAINT; Schema: public; Owner: sotoshop

--


ALTER TABLE ONLY items

ADD CONSTRAINT fk_items_category_id_categories_id FOREIGN KEY (category_id) REFERENCES categories(id) ON UPDATE CASCADE ON DELETE RESTRICT;


--

-- Name: public; Type: ACL; Schema: -; Owner: postgres

--


REVOKE ALL ON SCHEMA public FROM PUBLIC;

REVOKE ALL ON SCHEMA public FROM postgres;

GRANT ALL ON SCHEMA public TO postgres;

GRANT ALL ON SCHEMA public TO PUBLIC;


--

-- PostgreSQL database dump complete

--

Так же в этом разделе:
 
MyTetra Share v.0.59
Яндекс индекс цитирования