Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"syntax error at or near 'order'"" in PostgreSQL

I'm trying to add a column named order to my table. I realize that order is a reserved word in SQL. So, how do I do it? My command:

   alter table mytable add column order integer;

I've also tried:

   alter table mytable add column 'order' integer;

PostgreSQL 9.1.

like image 487
ed_is_my_name Avatar asked Oct 19 '25 14:10

ed_is_my_name


1 Answers

Use this:

alter table mytable add column "order" integer;

But, you might want to consider using a non-reserved name instead, like sort_order or something similar that reflects what the column is used for (and isn't a reserved word).

like image 117
jpw Avatar answered Oct 22 '25 03:10

jpw



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!