469,631 Members | 1,340 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

syntax error at or near "TYPE"

66
Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE public.postcodes
  2.   ALTER COLUMN machi
  3.   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:
Expand|Select|Wrap|Line Numbers
  1. -- Table: public.postcodes
  2.  
  3. -- DROP TABLE public.postcodes;
  4.  
  5. CREATE TABLE public.postcodes (
  6.   postcode  varchar(8) NOT NULL,
  7.   post      varchar(6) NOT NULL,
  8.   kencd     varchar(3) NOT NULL,
  9.   ken       varchar(30) NOT NULL,
  10.   shicd     varchar(4) NOT NULL,
  11.   shi       varchar(30) NOT NULL,
  12.   ku        varchar(30),
  13.   machi     varchar(30) NOT NULL,
  14.   status    boolean,
  15.   remarks   text,
  16.   /* Keys */
  17.   CONSTRAINT postcodes_pkey
  18.     PRIMARY KEY (postcode)
  19. ) WITHOUT OIDS;
  20.  
  21. ALTER TABLE public.postcodes
  22.   OWNER TO postgres; 
Jul 26 '07 #1
3 10567
michaelb
534 Expert 512MB
Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE public.postcodes  ALTER COLUMN machi  
  2.                      TYPE  varchar(100);
  3.  
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.
Jul 30 '07 #2
eros
66
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?.
Jul 31 '07 #3
michaelb
534 Expert 512MB
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
Aug 1 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Rich | last post: by
24 posts views Thread by carnold | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.