Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alter table error adding 2 columns

Tags:

postgresql

Database:POSTGRESQL

I have a table location_type with 2 columns id,name. I want to delete column name and add 2 other columns:county,city. However I get error and I can't figure out why. This is what I tried:

ALTER TABLE location_type
DROP COLUMN name;

ALTER TABLE location_type
ADD (county character varying(255) NOT NULL,
     city character varying(255) NOT NULL);

Maybe someone can see what I am doing wrong. Any suggestions are appreciated. Thanks.

like image 975
Fofole Avatar asked Jul 01 '26 18:07

Fofole


1 Answers

Your syntax is wrong. Try this [Doc]:

ALTER TABLE location_type
    ADD county character varying(255) NOT NULL,
    ADD city character varying(255) NOT NULL;
like image 173
Erkan Haspulat Avatar answered Jul 04 '26 19:07

Erkan Haspulat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!