SQL domain ERROR: column does not exist, setting default

前端 未结 3 1985
余生分开走
余生分开走 2021-01-27 03:43

I created a DOMAIN:

CREATE DOMAIN public.\"POSTAL_CODE\"
  AS character(5)
  NOT NULL;

I tried to set the default value:

ALTER          


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-27 04:28

    In SQL double quotes " are used to refer to a column or table named "select"

    A string constant in SQL is an arbitrary sequence of characters bounded by single quotes ('), for example 'This is a string'. So this is not the same as a double-quote character (")

    As a result you have to use single quote like below

    select * from test where old_code = '220088242'
    

    so in your case it should be like below

    ALTER DOMAIN public."POSTAL_CODE"
        SET DEFAULT '00000';
    

提交回复
热议问题