Hello everybody,
I have a question related to how to copy one table into another. Suppose that I have one table named "table1". What I want to do is to create another table named "table2" that contains exactly the same data stored in "table1". Here is how I usually proceed.
CREATE TABLE table2 AS
SELECT *
FROM table1;
Well, this works and it injects the whole set of data stored in "table1" into the table "table2". Yet, I noticed that by this method, not all the constraints of the "table1" are copied in "table2". I mean, all columns that were declared "NOT NULL" during "table1" definition are also considered to be "NOT NULL" in "table2". But other constraints such as primaery key, foreigne keys, etc. are not copied.
What I would like to know is whether there is a command allowing to do a deep copy, that is, copy both data and the whole set of the associated constraints from one table into another. In other words, creating the very same table just by a different name.
Thanks in advance,
Kind Regards,
Dariyoosh