Created
August 10, 2018 12:28
-
-
Save ivanelson/df750f49dbe6419f066bc797300b6baa to your computer and use it in GitHub Desktop.
add contrainst unique table already exists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE dbatez.rec_filial drop COLUMN pk_rec_filial; | |
ALTER TABLE dbatez.rec_filial ADD COLUMN pk_rec_filial bigserial UNIQUE; | |
ALTER TABLE dbatez.rec_filial ALTER COLUMN pk_rec_filial SET NOT NULL; | |
ALTER TABLE dbatez.rec_filial ALTER COLUMN pk_rec_filial SET DEFAULT nextval('dbatez.rec_filial_pk_rec_filial_seq'::regclass); | |
update dbatez.REC_FILIAL set pk_rec_filial = pk_rec_filial; | |
-- passar o ultimo elementro da sequence | |
select max(pk_rec_filial) from dbatez.rec_filial; | |
-- passar para ao setval | |
select setval('dbatez.rec_filial_pk_rec_filial_seq', 13557, true); | |
INSERT INTO dbatez.rec_filial | |
(sg_loja, sg_loja_cli, tp_contrato, tp_fin, nr_contrato, nr_prestacao, nr_parcela, cd_representante, cd_divisao, cd_cliente, dt_caixa, dt_pagamento, dt_vencimento, vl_prestacao, vl_juros, vl_desconto, no_cliente, sg_loja_ap, nr_recibo, qt_prestacao, fl_bordero, nr_bordero, sg_loja_posto, tp_recibo, fl_transfer, cd_chave, cd_chave_data, fl_enviado, cd_caixa, cd_chave_pkey, id_origin, id_remote, dth_criacao, dth_atualizacao) | |
VALUES('CAM', 'INR', 22, 3, 14687, 6, 0, 1, ' 1', 40818, '2008-11-05', '2008-11-05', '2008-10-13', 83.90, 5.96, 0.00, 'HELENITA DUARTE DOS SANTOS', 'CAM', 0, 10, 'S', ' 1236', ' 1', ' 2', '', 'TMA 2 3 4685 6 0', 'CAM20081105', NULL, NULL, 'CAM 10016', NULL, NULL, '2017-12-04 21:34:03.190', '2017-12-04 21:34:03.190'); | |
-- 13557 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment