syntax error at or near "TYPE"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eros
    New Member
    • Jun 2007
    • 66

    syntax error at or near "TYPE"

    Code:
    ALTER TABLE public.postcodes
      ALTER COLUMN machi
      TYPE varchar(100);
    Error: ERROR: syntax error at or near "TYPE";
    Error while executing the query (State:42601, Native Code: 7)


    I am using WinSQL, Windows XP SP2 Japanese Version, PostgreSQL 8.x.
    I want to alter my machi field from varchar(30) to varchar(100) TYPE.

    This is my CREATE TABLE script:
    Code:
    -- Table: public.postcodes
    
    -- DROP TABLE public.postcodes;
    
    CREATE TABLE public.postcodes (
      postcode  varchar(8) NOT NULL,
      post      varchar(6) NOT NULL,
      kencd     varchar(3) NOT NULL,
      ken       varchar(30) NOT NULL,
      shicd     varchar(4) NOT NULL,
      shi       varchar(30) NOT NULL,
      ku        varchar(30),
      machi     varchar(30) NOT NULL,
      status    boolean,
      remarks   text,
      /* Keys */
      CONSTRAINT postcodes_pkey
        PRIMARY KEY (postcode)
    ) WITHOUT OIDS;
    
    ALTER TABLE public.postcodes
      OWNER TO postgres;
  • michaelb
    Recognized Expert Contributor
    • Nov 2006
    • 534

    #2
    Originally posted by eros
    [CODE=sql]
    ALTER TABLE public.postcode s ALTER COLUMN machi
    TYPE varchar(100);
    [/CODE]
    This looks correct, but changing the column datatype was not supported in the versions prior to 8.x.
    My first thought is you are running an earlier version of PostgreSQL.

    Comment

    • eros
      New Member
      • Jun 2007
      • 66

      #3
      Originally posted by michaelb
      This looks correct, but changing the column datatype was not supported in the versions prior to 8.x.
      My first thought is you are running an earlier version of PostgreSQL.
      I am using PostgreSQL 7.4.1. Is there a documentation that the above scripts are not supported?.

      Comment

      • michaelb
        Recognized Expert Contributor
        • Nov 2006
        • 534

        #4
        Of course it is all well documented.
        Compare the ALTER TABLE command for 8.2 with that of 7.4 and you'll see the difference.
        The commonly used work around is to add a new column, copy the values from the old one, than drop the old column

        Comment

        Working...