By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

syntax error at or near "TYPE"

P: 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
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 534
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

P: 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

Expert 100+
P: 534
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.