0

I have an existing table called schools and trying to add a teachers column as follows; however, I want to add teachers columns right before the updated_at column; therefore, my script is as follows. But when I run my script it does not do anything, wondering if I am doing something wrong.

ALTER TABLE schools rename to old_schools;
CREATE TABLE schools
(
    user_id character varying(50) PRIMARY KEY,
    status character varying(100) NOT NULL,
    teachers text [] NOT NULL DEFAULT '{}'
    updated_at bigint NOT NULL,
);
INSERT INTO schools
    (user_id, owner_id, status, updated_at)
select user_id, owner_id, status, updated_at
from old_schools;
casillas
  • 16,351
  • 19
  • 115
  • 215
  • 1
    Does this answer your question? [How to add a new Column in a table after the 2nd or 3rd column in the Table using postgres?](https://stackoverflow.com/questions/1243547/how-to-add-a-new-column-in-a-table-after-the-2nd-or-3rd-column-in-the-table-usin) – Nikhil Patil Dec 07 '20 at 04:28
  • 1
    please be more informative about `dose not do anything` . and by just looking into query there is no `owner_id` in new `schools` table. – T. Peter Dec 07 '20 at 05:43

0 Answers0