CREATE SCHEMA spl AUTHORIZATION root;

DROP TABLE IF EXISTS spl.nsde;

CREATE SEQUENCE IF NOT EXISTS spl.nsde_id_seq
    INCREMENT 1
    START 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

ALTER SEQUENCE spl.nsde_id_seq
    OWNER TO root;

CREATE TABLE IF NOT EXISTS spl.nsde
(
    id integer NOT NULL DEFAULT nextval('spl.nsde_id_seq'::regclass),
    package_ndc11 character varying(11) COLLATE pg_catalog."default",
    application_number_or_citation character varying(25) COLLATE pg_catalog."default",
    package_ndc character varying(50) COLLATE pg_catalog."default",
    proprietary_name character varying(500) COLLATE pg_catalog."default",
    product_type character varying(90) COLLATE pg_catalog."default",
    marketing_category character varying(160) COLLATE pg_catalog."default",
    dosage_form character varying(155) COLLATE pg_catalog."default",
    billing_unit character varying(35) COLLATE pg_catalog."default",
    marketing_start_date date,
    marketing_end_date date,
    inactivation_date date,
    reactivation_date date,
    CONSTRAINT nsde_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS spl.nsde
    OWNER to root;
	
-- if the table is dropped, the sequence is as well
ALTER SEQUENCE spl.nsde_id_seq
    OWNED BY spl.nsde.id;
