471,852 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,852 software developers and data experts.

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 11589
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
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.