CREATE TABLE m_kanri(
	kn_cd char(3) PRIMARY KEY,
	kn_name varchar(30) NOT NULL,
	kn_yuubin varchar(10),
	kn_ado varchar(100),
	kn_phone varchar(20),
	kn_fax varchar(20),
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE m_kanri IS '管理マスタ';

COMMENT ON COLUMN m_kanri.kn_cd IS '管理先コード';
COMMENT ON COLUMN m_kanri.kn_name IS '会社名';
COMMENT ON COLUMN m_kanri.kn_yuubin IS '郵便番号';
COMMENT ON COLUMN m_kanri.kn_ado IS '住所';
COMMENT ON COLUMN m_kanri.kn_phone IS '電話番号';
COMMENT ON COLUMN m_kanri.kn_fax IS 'FAX番号';
COMMENT ON COLUMN m_kanri.update_date IS '更新日';
COMMENT ON COLUMN m_kanri.create_date IS '作成日';

INSERT INTO m_kanri VALUES ('000', '片山撚糸株式会社', '491-0046', '一宮市天王3丁目3-33', '(0586)45-3648', '(0586)46-1492', now(), now());

/*----------------------------------------------------------- */

CREATE TABLE m_tokui(
	tk_cd char(3) PRIMARY KEY,
	tk_name varchar(30) NOT NULL,
	tk_yuubin char(7),
	tk_ado varchar(100),
	tk_phone varchar(20),
	tk_fax varchar(20),
	hasu_flg char(1) NOT NULL DEFAULT 0,
	syohi_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE m_tokui IS '得意先マスタ';

COMMENT ON COLUMN m_tokui.tk_cd IS '得意先コード';
COMMENT ON COLUMN m_tokui.tk_name IS '得意先名';
COMMENT ON COLUMN m_tokui.tk_yuubin IS '郵便番号';
COMMENT ON COLUMN m_tokui.tk_ado IS '住所';
COMMENT ON COLUMN m_tokui.tk_phone IS '電話番号';
COMMENT ON COLUMN m_tokui.tk_fax IS 'FAX番号';
COMMENT ON COLUMN m_tokui.hasu_flg IS '端数区分(0:切捨て, 1:四捨五入)';
COMMENT ON COLUMN m_tokui.syohi_flg IS '消費税区分(0:消費税切捨て, 1:消費税四捨五入)';
COMMENT ON COLUMN m_tokui.update_date IS '更新日';
COMMENT ON COLUMN m_tokui.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE m_gaichu(
	gc_cd char(3) PRIMARY KEY,
	gc_name varchar(30) NOT NULL,
	gc_yuubin char(7),
	gc_ado varchar(100),
	gc_phone varchar(20),
	gc_fax varchar(20),
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE m_gaichu IS '外注先マスタ';

COMMENT ON COLUMN m_gaichu.gc_cd IS '外注先コード';
COMMENT ON COLUMN m_gaichu.gc_name IS '外注先名';
COMMENT ON COLUMN m_gaichu.gc_yuubin IS '郵便番号';
COMMENT ON COLUMN m_gaichu.gc_ado IS '住所';
COMMENT ON COLUMN m_gaichu.gc_phone IS '電話番号';
COMMENT ON COLUMN m_gaichu.gc_fax IS 'FAX番号';
COMMENT ON COLUMN m_gaichu.update_date IS '更新日';
COMMENT ON COLUMN m_gaichu.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE m_syuka(
	sk_cd char(3) PRIMARY KEY,
	sk_name varchar(30) NOT NULL,
	sk_yuubin char(7),
	sk_ado varchar(100),
	sk_phone varchar(20),
	sk_fax varchar(20),
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE m_syuka IS '出荷先マスタ';

COMMENT ON COLUMN m_syuka.sk_cd IS '出荷先コード';
COMMENT ON COLUMN m_syuka.sk_name IS '外注先名';
COMMENT ON COLUMN m_syuka.sk_yuubin IS '郵便番号';
COMMENT ON COLUMN m_syuka.sk_ado IS '住所';
COMMENT ON COLUMN m_syuka.sk_phone IS '電話番号';
COMMENT ON COLUMN m_syuka.sk_fax IS 'FAX番号';
COMMENT ON COLUMN m_syuka.update_date IS '更新日';
COMMENT ON COLUMN m_syuka.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE m_nyuka(
	nk_cd char(3) PRIMARY KEY,
	nk_name varchar(30) NOT NULL,
	nk_yuubin char(7),
	nk_ado varchar(100),
	nk_phone varchar(20),
	nk_fax varchar(20),
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE m_nyuka IS '入荷先マスタ';

COMMENT ON COLUMN m_nyuka.nk_cd IS '入荷先コード';
COMMENT ON COLUMN m_nyuka.nk_name IS '外注先名';
COMMENT ON COLUMN m_nyuka.nk_yuubin IS '郵便番号';
COMMENT ON COLUMN m_nyuka.nk_ado IS '住所';
COMMENT ON COLUMN m_nyuka.nk_phone IS '電話番号';
COMMENT ON COLUMN m_nyuka.nk_fax IS 'FAX番号';
COMMENT ON COLUMN m_nyuka.update_date IS '更新日';
COMMENT ON COLUMN m_nyuka.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE m_kubun(
	kb_cd varchar(20) NOT NULL,
	kb_name varchar(10) NOT NULL,
	kb_meisyo varchar(100),
	kb_bikou varchar(100),
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now(),
	PRIMARY KEY (kb_cd, kb_name)
);

COMMENT ON TABLE m_kubun IS '区分マスタ';

COMMENT ON COLUMN m_kubun.kb_cd IS '区分種別';
COMMENT ON COLUMN m_kubun.kb_name IS '区分';
COMMENT ON COLUMN m_kubun.kb_meisyo IS '区分名称';
COMMENT ON COLUMN m_kubun.kb_bikou IS '備考';
COMMENT ON COLUMN m_kubun.update_date IS '更新日';
COMMENT ON COLUMN m_kubun.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_zyuchu(
	zc_cd char(9) PRIMARY KEY,
	zc_date timestamp without time zone NOT NULL,
	zc_tkcd char(3) NOT NULL,
	zc_productlot varchar(20),
	zc_name varchar(24),
	zc_bante varchar(15),
	zc_colorban varchar(15),
	zc_lot varchar(15),
	zc_shitate varchar(5),
	zc_zyuchu numeric(8,3),
	zc_tanka numeric(5),
	zc_cond1 varchar(50),
	zc_cond2 varchar(50),
	zc_bikou varchar(80),
	comp_flg char(1) NOT NULL DEFAULT 0,
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE t_zyuchu IS '受注';

COMMENT ON COLUMN t_zyuchu.zc_cd IS '受注管理コード(YYMMDD000 下3桁は連番)';
COMMENT ON COLUMN t_zyuchu.zc_date IS '受注日';
COMMENT ON COLUMN t_zyuchu.zc_tkcd IS '得意先コード';
COMMENT ON COLUMN t_zyuchu.zc_productlot IS '製品ロット';
COMMENT ON COLUMN t_zyuchu.zc_name IS '品名';
COMMENT ON COLUMN t_zyuchu.zc_bante IS '番手';
COMMENT ON COLUMN t_zyuchu.zc_colorban IS '色番';
COMMENT ON COLUMN t_zyuchu.zc_lot IS 'ロット';
COMMENT ON COLUMN t_zyuchu.zc_shitate IS '仕立';
COMMENT ON COLUMN t_zyuchu.zc_zyuchu IS '受注数';
COMMENT ON COLUMN t_zyuchu.zc_tanka IS '単価';
COMMENT ON COLUMN t_zyuchu.zc_cond1 IS '条件1';
COMMENT ON COLUMN t_zyuchu.zc_cond2 IS '条件2';
COMMENT ON COLUMN t_zyuchu.zc_bikou IS '備考';
COMMENT ON COLUMN t_zyuchu.comp_flg IS '完納フラグ(0:受注中 1:完納)';
COMMENT ON COLUMN t_zyuchu.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_zyuchu.update_date IS '更新日';
COMMENT ON COLUMN t_zyuchu.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_nyuka(
	nk_cd char(9) NOT NULL,
	nk_edaban char(2) NOT NULL,
	nk_date timestamp without time zone NOT NULL,
	nk_name varchar(24) NOT NULL,
	nk_bante varchar(15),
	nk_colorban varchar(15),
	nk_tkcd char(3) NOT NULL,
	nk_tkname varchar(30),
	nk_nksuu numeric(8,3) NOT NULL,
	nk_kosuu numeric(3),
	nk_bikou varchar(40),
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now(),
	PRIMARY KEY (nk_cd, nk_edaban)
);

COMMENT ON TABLE t_nyuka IS '入荷';

COMMENT ON COLUMN t_nyuka.nk_cd IS '受注管理コード(YYMMDD000 下3桁は連番)';
COMMENT ON COLUMN t_nyuka.nk_edaban IS '入荷枝番';
COMMENT ON COLUMN t_nyuka.nk_date IS '入荷日';
COMMENT ON COLUMN t_nyuka.nk_name IS '品名';
COMMENT ON COLUMN t_nyuka.nk_bante IS '番手';
COMMENT ON COLUMN t_nyuka.nk_colorban IS '色番';
COMMENT ON COLUMN t_nyuka.nk_tkcd IS '入荷先コード';
COMMENT ON COLUMN t_nyuka.nk_tkname IS '入荷先名';
COMMENT ON COLUMN t_nyuka.nk_nksuu IS '入荷数';
COMMENT ON COLUMN t_nyuka.nk_kosuu IS '個数';
COMMENT ON COLUMN t_nyuka.nk_bikou IS '備考';
COMMENT ON COLUMN t_nyuka.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_nyuka.update_date IS '更新日';
COMMENT ON COLUMN t_nyuka.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_syuka(
	sk_cd char(10) PRIMARY KEY,
	sk_tkcd char(3) NOT NULL,
	sk_skcd char(3) NOT NULL,
	sk_skname varchar(30),
	sk_date timestamp without time zone,
	sk_suryo numeric(9,3),
	sk_kosuu numeric(4),
	sk_yakuzyo varchar(50),
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE t_syuka IS '出荷';

COMMENT ON COLUMN t_syuka.sk_cd IS '出荷伝票コード';
COMMENT ON COLUMN t_syuka.sk_tkcd IS '得意先コード';
COMMENT ON COLUMN t_syuka.sk_skcd IS '出荷先コード';
COMMENT ON COLUMN t_syuka.sk_skname IS '出荷先名';
COMMENT ON COLUMN t_syuka.sk_date IS '出荷日';
COMMENT ON COLUMN t_syuka.sk_suryo IS '総数量';
COMMENT ON COLUMN t_syuka.sk_kosuu IS '総個数';
COMMENT ON COLUMN t_syuka.sk_yakuzyo IS '約定先';
COMMENT ON COLUMN t_syuka.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_syuka.update_date IS '更新日';
COMMENT ON COLUMN t_syuka.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_syukadetail(
	skda_cd char(9) NOT NULL,
	skda_edaban char(2) NOT NULL,
	skda_sksuu numeric(8,3),
	skda_kosuu numeric(3),
	skda_bikou varchar(40),
	zaiko_flg char(1) NOT NULL DEFAULT 0,
	azukari_flg char(1) NOT NULL DEFAULT 0,
	comp_flg char(1) NOT NULL DEFAULT 0,
	skda_skcd char(10) NOT NULL,
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now(),
	PRIMARY KEY (skda_cd, skda_edaban)
);

COMMENT ON TABLE t_syukadetail IS '出荷詳細';

COMMENT ON COLUMN t_syukadetail.skda_cd IS '外注管理コード(YYMMDD000 下3桁は連番)';
COMMENT ON COLUMN t_syukadetail.skda_edaban IS '出荷枝番';
COMMENT ON COLUMN t_syukadetail.skda_sksuu IS '出荷数';
COMMENT ON COLUMN t_syukadetail.skda_kosuu IS '個数';
COMMENT ON COLUMN t_syukadetail.skda_bikou IS '備考';
COMMENT ON COLUMN t_syukadetail.zaiko_flg IS '製品在庫フラグ(1:製品在庫)';
COMMENT ON COLUMN t_syukadetail.azukari_flg IS '預出荷フラグ(1:預出荷)';
COMMENT ON COLUMN t_syukadetail.comp_flg IS '完納フラグ(1:完納)';
COMMENT ON COLUMN t_syukadetail.skda_skcd IS '出荷伝票コード(SYYYMMDD00 下2桁は連番)';
COMMENT ON COLUMN t_syukadetail.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_syukadetail.update_date IS '更新日';
COMMENT ON COLUMN t_syukadetail.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_seikyu(
	sek_cd char(10) PRIMARY KEY,
	sek_tkcd char(3) NOT NULL,
	sek_date timestamp without time zone NOT NULL,
	sek_suryo numeric(12,3),
	sek_goukei numeric(9),
	sek_syohi numeric(7),
	sek_sougoukei numeric(9),
	sek_unchin numeric(6),
	sek_zairyo numeric(6),
	sek_itodai numeric(6),
	sek_sonota numeric(6),
	sek_gaku numeric(9),
	hasu_flg char(1) NOT NULL DEFAULT 0,
	syohi_flg char(1) NOT NULL DEFAULT 0,
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE t_seikyu IS '請求';

COMMENT ON COLUMN t_seikyu.sek_cd IS '請求先コード';
COMMENT ON COLUMN t_seikyu.sek_tkcd IS '得意先コード';
COMMENT ON COLUMN t_seikyu.sek_date IS '請求日';
COMMENT ON COLUMN t_seikyu.sek_suryo IS '総数量';
COMMENT ON COLUMN t_seikyu.sek_goukei IS '合計';
COMMENT ON COLUMN t_seikyu.sek_syohi IS '消費税';
COMMENT ON COLUMN t_seikyu.sek_sougoukei IS '総合計';
COMMENT ON COLUMN t_seikyu.sek_unchin IS '運賃';
COMMENT ON COLUMN t_seikyu.sek_zairyo IS '材料';
COMMENT ON COLUMN t_seikyu.sek_itodai IS '糸代';
COMMENT ON COLUMN t_seikyu.sek_sonota IS 'その他';
COMMENT ON COLUMN t_seikyu.sek_gaku IS '請求額';
COMMENT ON COLUMN t_seikyu.hasu_flg IS '端数区分(0:切捨て, 1:四捨五入)';
COMMENT ON COLUMN t_seikyu.syohi_flg IS '消費税区分(0:消費税切捨て, 1:消費税四捨五入)';
COMMENT ON COLUMN t_seikyu.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_seikyu.update_date IS '更新日';
COMMENT ON COLUMN t_seikyu.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_seikyudetail(
	sekda_cd char(9) NOT NULL,
	sekda_sykedaban char(2) NOT NULL,
	sekda_sekedaban char(2) NOT NULL,
	sekda_seikyu numeric(8,3),
	sekda_tanka numeric(5),
	sekda_kingaku numeric(8),
	sekda_skcd char(10) NOT NULL,
	hasu_flg char(1) NOT NULL DEFAULT 0,
	syohi_flg char(1) NOT NULL DEFAULT 0,
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now(),
	PRIMARY KEY (sekda_cd, sekda_sykedaban, sekda_sekedaban)
);

COMMENT ON TABLE t_seikyudetail IS '請求詳細';

COMMENT ON COLUMN t_seikyudetail.sekda_cd IS '受注管理コード(YYMMDD000 下3桁は連番)';
COMMENT ON COLUMN t_seikyudetail.sekda_sykedaban IS '出荷枝番';
COMMENT ON COLUMN t_seikyudetail.sekda_sekedaban IS '請求枝番';
COMMENT ON COLUMN t_seikyudetail.sekda_seikyu IS '請求数';
COMMENT ON COLUMN t_seikyudetail.sekda_tanka IS '単価';
COMMENT ON COLUMN t_seikyudetail.sekda_kingaku IS '金額';
COMMENT ON COLUMN t_seikyudetail.sekda_skcd IS '請求書コード(SIYYMMDD00 下2桁は連番)';
COMMENT ON COLUMN t_seikyudetail.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_seikyudetail.update_date IS '更新日';
COMMENT ON COLUMN t_seikyudetail.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_gaichu(
	gc_cd char(8) PRIMARY KEY,
	gc_zccd char(9) NOT NULL,
	gc_date timestamp without time zone NOT NULL,
	gc_tkcd char(3) NOT NULL,
	gc_name varchar(24),
	gc_bante varchar(15),
	gc_colorban varchar(15),
	gc_lot varchar(15),
	gc_shitate varchar(5),
	gc_keiyakusuu numeric(8,3),
	gc_cond1 varchar(50),
	gc_cond2 varchar(50),
	gc_bikou varchar(80),
	comp_flg char(1) NOT NULL DEFAULT 0,
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE t_gaichu IS '外注';

COMMENT ON COLUMN t_gaichu.gc_cd IS '外注管理コード(YYMMDD00 下2桁は連番)';
COMMENT ON COLUMN t_gaichu.gc_zccd IS '受注管理コード(YYMMDD000 下3桁は連番)';
COMMENT ON COLUMN t_gaichu.gc_date IS '依頼日';
COMMENT ON COLUMN t_gaichu.gc_tkcd IS '外注先コード';
COMMENT ON COLUMN t_gaichu.gc_name IS '品名';
COMMENT ON COLUMN t_gaichu.gc_bante IS '番手';
COMMENT ON COLUMN t_gaichu.gc_colorban IS '色番';
COMMENT ON COLUMN t_gaichu.gc_lot IS 'ロット';
COMMENT ON COLUMN t_gaichu.gc_shitate IS '仕立';
COMMENT ON COLUMN t_gaichu.gc_keiyakusuu  IS '契約数';
COMMENT ON COLUMN t_gaichu.gc_cond1 IS '条件1';
COMMENT ON COLUMN t_gaichu.gc_cond2 IS '条件2';
COMMENT ON COLUMN t_gaichu.gc_bikou IS '備考';
COMMENT ON COLUMN t_gaichu.comp_flg IS '完納フラグ(0:受注中 1:完納)';
COMMENT ON COLUMN t_gaichu.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_gaichu.update_date IS '更新日';
COMMENT ON COLUMN t_gaichu.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_gaichusyuka(
	gcsk_cd char(8) NOT NULL,
	gcsk_edaban char(2) NOT NULL,
	gcsk_date timestamp without time zone NOT NULL,
	gcsk_name varchar(24),
	gcsk_bante varchar(15),
	gcsk_colorban varchar(15),
	gcsk_sksuu numeric(8,3) NOT NULL,
	gcsk_kosuu numeric(3),
	gcsk_bikou varchar(50),
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now(),
	PRIMARY KEY (gcsk_cd, gcsk_edaban)
);

COMMENT ON TABLE t_gaichusyuka IS '外注出荷';

COMMENT ON COLUMN t_gaichusyuka.gcsk_cd IS '外注管理コード(YYMMDD00 下2桁は連番)';
COMMENT ON COLUMN t_gaichusyuka.gcsk_edaban IS '出荷枝番';
COMMENT ON COLUMN t_gaichusyuka.gcsk_date IS '出荷日';
COMMENT ON COLUMN t_gaichusyuka.gcsk_name IS '品名';
COMMENT ON COLUMN t_gaichusyuka.gcsk_bante IS '番手';
COMMENT ON COLUMN t_gaichusyuka.gcsk_colorban IS '色番';
COMMENT ON COLUMN t_gaichusyuka.gcsk_sksuu IS '出荷数';
COMMENT ON COLUMN t_gaichusyuka.gcsk_kosuu IS '個数';
COMMENT ON COLUMN t_gaichusyuka.gcsk_bikou IS '備考';
COMMENT ON COLUMN t_gaichusyuka.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_gaichusyuka.update_date IS '更新日';
COMMENT ON COLUMN t_gaichusyuka.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_gaichuukeire(
	gcui_cd char(8) NOT NULL,
	gcui_edaban char(2) NOT NULL,
	gcui_date timestamp without time zone NOT NULL,
	gcui_uisuu numeric(8,3) NOT NULL,
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now(),
	PRIMARY KEY (gcui_cd, gcui_edaban)
);

COMMENT ON TABLE t_gaichuukeire IS '外注受入';

COMMENT ON COLUMN t_gaichuukeire.gcui_cd IS '外注管理コード(YYMMDD00 下2桁は連番)';
COMMENT ON COLUMN t_gaichuukeire.gcui_edaban IS '受入枝番';
COMMENT ON COLUMN t_gaichuukeire.gcui_date IS '受入日';
COMMENT ON COLUMN t_gaichuukeire.gcui_uisuu IS '受入数';
COMMENT ON COLUMN t_gaichuukeire.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_gaichuukeire.update_date IS '更新日';
COMMENT ON COLUMN t_gaichuukeire.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_shiha(
	sh_cd char(10) PRIMARY KEY,
	sh_gccd char(3) NOT NULL,
	sh_date timestamp without time zone NOT NULL,
	sh_suryo numeric(12,3),
	sh_goukei numeric(9),
	sh_syohi numeric(7),
	sh_buhindai numeric(6),
	sh_sonota numeric(6),
	sh_sougoukei numeric(9),
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now()
);

COMMENT ON TABLE t_shiha IS '支払';

COMMENT ON COLUMN t_shiha.sh_cd IS '支払伝票コード(SIYYMMDD00 下2桁は連番)';
COMMENT ON COLUMN t_shiha.sh_gccd IS '外注先コード';
COMMENT ON COLUMN t_shiha.sh_date IS '支払日';
COMMENT ON COLUMN t_shiha.sh_suryo IS '総数量';
COMMENT ON COLUMN t_shiha.sh_goukei IS '合計';
COMMENT ON COLUMN t_shiha.sh_syohi IS '消費税';
COMMENT ON COLUMN t_shiha.sh_buhindai IS '部品代';
COMMENT ON COLUMN t_shiha.sh_sonota IS 'その他';
COMMENT ON COLUMN t_shiha.sh_sougoukei IS '総合計';
COMMENT ON COLUMN t_shiha.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_shiha.update_date IS '更新日';
COMMENT ON COLUMN t_shiha.create_date IS '作成日';

/*----------------------------------------------------------- */

CREATE TABLE t_shihadetail(
	shda_cd char(8) NOT NULL,
	shda_uiaban char(2) NOT NULL,
	shda_shaban char(2) NOT NULL,
	shda_shiha numeric(8,3),
	shda_tanka numeric(5),
	shda_kingaku numeric(8),
	shda_shcd char(10) NOT NULL,
	del_flg char(1) NOT NULL DEFAULT 0,
	update_date timestamp NOT NULL DEFAULT now(),
	create_date timestamp NOT NULL DEFAULT now(),
	PRIMARY KEY (shda_cd, shda_uiaban, shda_shaban)
);

COMMENT ON TABLE t_shihadetail IS '支払詳細';

COMMENT ON COLUMN t_shihadetail.shda_cd IS '外注管理コード(YYMMDD00 下2桁は連番)';
COMMENT ON COLUMN t_shihadetail.shda_uiaban IS '受入枝番';
COMMENT ON COLUMN t_shihadetail.shda_shaban IS '支払枝番';
COMMENT ON COLUMN t_shihadetail.shda_shiha IS '支払数';
COMMENT ON COLUMN t_shihadetail.shda_tanka IS '単価';
COMMENT ON COLUMN t_shihadetail.shda_kingaku IS '金額';
COMMENT ON COLUMN t_shihadetail.shda_shcd IS '支払伝票コード(SIYYMMDD00 下2桁は連番)';
COMMENT ON COLUMN t_shihadetail.del_flg IS '削除フラグ(1:削除)';
COMMENT ON COLUMN t_shihadetail.update_date IS '更新日';
COMMENT ON COLUMN t_shihadetail.create_date IS '作成日';

/*----------------------------------------------------------- */

