In this article, I explain how we can create the new table to be created based on a different table, with and without data.
I will use veliler table for this example.
First, let’s see veliler table.
With the help of the create table command below, we can create the same veliler table without data.
CREATE TABLE veliler_datasız AS (SELECT * FROM veliler )WITH NO DATA;
With the help of the create table command below, we create the same veliler table with a different name with the data in it.
As seen above, we created our data and we created and transferred veliler_datalı table with 8 records in it.
While performing these operations, the data types are generally the same, but in some cases, postgresql can choose the data type itself and set the appropriate data type.
After these operations, I recommend you to check the data types.