I need to do a procedure that copies from my table TAB_FORNECEDOR, everything in it and go to table TAB_FORNECEDOR2.
I need to make a cursor with a loop, a delete with commit first of all, can you give me a light on how to mount my procedure?
I need to do a procedure that copies from my table TAB_FORNECEDOR, everything in it and go to table TAB_FORNECEDOR2.
I need to make a cursor with a loop, a delete with commit first of all, can you give me a light on how to mount my procedure?
One solution is to create the table from scratch with data from the previous one:
CREATE TABLE
TAB_FORNECEDOR2
AS
SELECT
*
FROM
TAB_FORNECEDOR;
Remembering that you should remove TAB_FORNECEDOR2 if it already exists.
If you just need to keep both synced, better give more detail on the question.
Important : If you need to define constraints on the copy, you have to do this manually, as CREATE AS
does not copy indexes, triggers, etc. >
If you want to copy only the data, you can use this syntax:
INSERT INTO
TAB_FORNECEDOR2 (
campo1,
campo2
...
)
SELECT
TAB_FORNECEDOR.campo1 ...
FROM
TAB_FORNECEDOR
And optionally you can use WHERE
to filter the desired rows.