'How to add default values in custom columns in postgres sql

I have created Custom columns by

 SELECT 'CREATE VIEW myview AS SELECT ' ||
    string_agg(
      format(
         '%I AS %I',
         column_name,
        column_name|| '_' || '__err_mandatory'
      ) ,
      ', '
         ORDER BY ordinal_position
   ) ||
   format(' FROM %I.%I', table_schema, table_name) AS C
  FROM information_schema.columns
 WHERE table_schema = 'public'
 AND table_name = 'act_1_customer_16510427dfdg66600'
GROUP BY table_name, table_schema;

View is created like below

CREATE VIEW myview AS SELECT __id AS __id___err_mandatory, 
 col_1_1651042811002 AS 
 col_1_1651042811002___err_mandatory, col_2_1651042811004 AS 
 col_2_1651042811004___err_mandatory, col_3_1651042811005 AS 
 col_3_1651042811005___err_mandatory, col_4_1651042811007 AS  FROM 
  public.act_1_customer_16510427dfdg66600

But i can not add default value to each custom column How to do?



Solution 1:[1]

I managed to enter this way.

INSERT INTO myview (cd_ace___err_mandatory, no_desc___err_mandatory) VALUES (200,DEFAULT);

I hope I've helped.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andronicus