SQL domain ERROR: column does not exist, setting default

前端 未结 3 1977
余生分开走
余生分开走 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:09

    Try this: value should be in single quote like '00000'

    ALTER DOMAIN public."POSTAL_CODE" set default '00000';
    
    0 讨论(0)
  • 2021-01-27 04:19

    Try this

    Alter table <table name> ALTER <column name> TYPE character varying, ALTER <column name> SET DEFAULT '00000'
    
    0 讨论(0)
  • 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';
    
    0 讨论(0)
提交回复
热议问题